ThemeShaper Forums » Thematic

[closed]

filtering category from loop breaks page navigation

(2 posts)
  • Started 11 years ago by flippingtires
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. flippingtires
    Member

    Hi,

    We need to display our news category posts on their own separate page. So I filtered the category from the main index as Chris described here:

    http://forums.themeshaper.com/topic/filtering-one-category-from-index-loop

    '
    //Remove news category from blog page to avoid double posting
    function no_news_in_loop() {
    //test if we are on the blog page
    if(is_home())

    {
    global $query_string;
    query_posts('cat=-3');
    }
    }
    add_action('thematic_indexloop', 'no_news_in_loop');
    '

    It works great, almost. It causes my pagination links to stop working. They load the appropriate page, i.e. blog/page/2/ and blog/page/3/, but the posts on every page are the same.

    I'm hoping there's a quick and easy fix for it? I just can't seem to locate one.

    I suppose I should also mention that I've put the news category posts on their own page by copying page.php, renaming in to page-news.php, and creating a page template with it. I then filter the index loop on that page with this function:

    '
    //filter news category posts to only show on news page template

    function news_in_loop () {
    if(is_page_template('page-news.php'))

    {
    query_posts( $query_string . "&cat=26");
    }
    }

    add_action('thematic_indexloop', 'news_in_loop');
    '

    This also works as needed, except for the same pagination issue.

    Thanks for your help.

    Posted 11 years ago #
  2. yup, b/c query_posts('cat=-3'); means you've killed the other bits in your query... that tell WP what paginated page you are on. so you should either include the pagination parts (which i think might be shown on the blog template... i dont remember)

    OR
    safely tack your args on to the query instead of completely replacing it

    global $wp_query;
    $args = array_merge( $wp_query->query, array( 'cat'=>-3 ) );
    query_posts( $args );

    which is straight out of the Codex
    http://codex.wordpress.org/Function_Reference/query_posts

    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.