Displaying posts of a certain category on a different page
Hello! I found this very useful looking post from a while back, explaining how to show a certain category of posts on a separate page and exclude them from the main home page.
I’ve just tried it and it isn’t working for me. I wonder if I am adding the wrong post category ID to the snippet of code from the link above. I found my desired category in the wp_terms table and used field term_id – the value is 1455. Is that the correct place to find Category ID?
Just to give all the details, I named the page which will display my particular category of post: potd and I named the php file page-potd.php. I have placed this file in the following directory:
(graphene-child is the unimaginative name of my child theme). Here are the contents of page-potd.php:
$cat = 1455; // This should be the ID of the category to display the posts from
$args = wp_parse_args(array('cat' => $cat, 'paged' => get_query_var('paged')), $query_string);
$wp_query->is_home = true;
Can anyone spot a problem? I know that forum post I quoted is a few years old, so I’m not sure if I’ve made a mistake or if some of that advice has been superseded. Any advice gratefully received. Thanks,
You must be logged in to reply to this topic.