• On the site index.php i have $cat = 2; to it will fetch all posts on main page in category 2, which are the news posts. On the sidebar i want to fetch a list of all post titles in category 3. The problem is i am using query_posts. When I use this, it lists the posts, and lists the main page posts, but when i try clicking on a post, it doesn’t want to load it, it is as if i have hardcoded for it to display a specific post. not sure what is going on, anyone ever run into this (displaying posts of one category on main page, and list all post titles on sidebar).

    thanks

Viewing 1 replies (of 1 total)
  • As I’ve learned (unwillingly), when query_posts() acts up by either not working as expected or interfering with other $post objects, it’s time to initialize a new query instance with WP_Query. Example:

    <?php
    $query = new WP_Query('cat=3');
    if ($query->have_posts()) : while($query->have_posts() : $query->the_post();
    ?>

    WP_Query() accepts the same arguments as query_posts().

Viewing 1 replies (of 1 total)
  • The topic ‘query_posts category specific index page’ is closed to new replies.