Add Categories to Posts Page

Hello, I would like to add a list of the blog categories to the posts page of a website without using a sidebar or anything like that. Just the categories at the top of the page and the rest of the posts page stays the same. I have found many ways to this with shortcodes and/or plugins but none of them pertain to the posts page since I know of no way to enter shortcode on that page. Please advise.

Thanks in advance.

Hello @GreaterGoodSolutions,

Thanks for asking. :slight_smile:

You can use plugin like List categories to list all categories in a post page. You can take a look at the tutorial here. http://www.wpbeginner.com/plugins/how-to-list-category-posts-in-a-wordpress-post-or-page-with-shortcode/

Please note that the plugin name I have shared is not a Themeco official advice. It’s a personal input that I am sharing with you. We won’t be able to provide support in case any issues come up because of above plugin.

Thanks.

Thank you for the information but the issue is that I need the categories listed on the main posts page, the one generated by WP. There is no place to enter content (such as a shortcode) on this page like there is on a standard post or page. Changes made in Cornerstone have no effect. Screencap -

Hello @GreaterGoodSolutions,

Thanks for updating the thread.

Ohh, okay. Now I got your point. Once you set a page as your Posts Page under Settings > Reading > Post page, you can no longer edit that page in Cornerstone and even using the default WordPress editor. That is because the contents will be dynamically generated by WordPress. More information can be found on following article:

https://codex.wordpress.org/Creating_a_Static_Front_Page#Creating_a_Static_Front_Page

Thanks.

Hello, I understand how to make a static front page and that once a page is designated as the posts page that it’s content is generated dynamically. My question is, how can I list the categories on a page that displays all of the blog posts like the dynamically generated page does? Or, how can I edit the post page to display the categories. Thank you.

Hi,

What you trying to achieve requires custom code which is outside the scope of support that we offer.

We can point you into the right direction so you will have something to start with.

Try adding this code in your child theme’s functions.php file

function add_categories() {
    if(is_home()) {  ?>
        <div class="x-container max width"</div>
            <?php echo get_the_category_list(); ?>
        </div>
        <?php
    }
}
add_action( 'x_after_view_global__slider-below', 'add_categories', 10 );

Okay thank you, I understand. It seems awfully strange that WP would offer categories and then make it difficult to display those categories on the same page as the posts.

You are most welcome. :slight_smile:

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