Displaying posts of a certain category on a different page

  • Anonymous

    #8964

    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:

    /public_html/wp-content/themes/graphene-child

    (graphene-child is the unimaginative name of my child theme). Here are the contents of page-potd.php:

    <?php
    global $graphene_settings;
    get_header();
    global $wp_query;
    $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);
    query_posts($args);
    $wp_query->is_home = true;

    get_template_part('loop', 'index');

    get_footer(); ?>

    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,

    Tom

    Mod

    Kenneth John Odle

    #42484

    The easiest way may be to use the Advanced Post List plugin:

    http://wordpress.org/plugins/advanced-post-list/

    Anonymous

    #42485

    Thanks Kenneth. I had a try with that one, but found it hugely complicated. Found this other one, List Category Posts, which seems a lot simpler (though less flexible/powerful I’m sure):

    Thanks again for your suggestion 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

  • You must be logged in to reply to this topic.