Blog Post Categories - Post

Hello, I have a client that would like to have 2 different categories of Blog Post. One would just be Health post and the other would be Video post. They would like the category descriptions to be sticky to the top of every post that is in the respective category. I have tried to add a sticky post but it does not anchor itself to the top of every page in the category. I’m not quite sure how to achieve this and I was hoping that you could push me in the right direction. Don’t spend a lot of time, just a little push in the right direction and I will follow your instructions.

Hey Scott,

Thanks for writing in. To achieve that, please try adding this php code to your child theme’s functions.php.

function show_category_description() {
    if( is_single() ){
        $catID = get_the_category();
        $description = category_description( $catID[0] ); 
        echo "<div class='x-container max'><h4>$description</h4></div>" ;
    }
}

add_action( 'x_after_masthead_end', 'show_category_description' );

From there you can edit the html and how it looks.

Let us know how it goes.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.