How do you add the category meta section above the entry title on single post details? I am sharing the simple step for this. I am using the free version of Astra theme.
Disabling The Category Meta for Single Post
At first we will disable the category meta option for single post. You can easily do it. Astra theme customizer have toggle option for it.
- Go to Astra theme customiser
- Click on Blog -> Single Post section
- Go to Meta section
- Click on the “EYE” icon of Category meta
Therefore category will not show below the title on single post page.
Displaying the Category above the Title
We need small PHP code for this. Open the functions.php file of your astra child theme and drop this PHP snippets at end of the file.
1 2 3 4 |
add_action( 'astra_single_post_title_before', 'paulc_add_category_above_title' ); function paulc_add_category_above_title() { printf( '<div class="entry-category-meta">%s</div>', astra_post_categories() ); } |
This simple PHP code is doing the tricks.
Lokendra Yadav says
This is not working in the latest version of Astra theme above 3.9.3.
Dave says
how do do it on the front page?
Dave says
How to do it for Blog/Archive? Thanks!
Jon says
Great tip, thanks!