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.
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() ); }