ThemeShaper Forums » Thematic

[closed]

Pagination in custom category loop

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

    First, thank you all for the enormous amount of information posted about thematic. I am about to launch my first huge project with it and it has been a great learning experience and success.

    I haven't been able to find information regrading pagination of a custom category loop.

    I have removed the original loop

    function remove_categoryloop() {
        remove_action('thematic_categoryloop', 'thematic_category_loop');
    }
    add_action('init', 'remove_categoryloop');

    Added a custom loop

    function my_categoryloop() {
    
    foreach(get_the_category() as $category) {
    $cat = $category->cat_ID; }
    
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        query_posts("paged=$paged&cat=' . $cat . '");
    
    while (have_posts()) : the_post(); ?>
    
          <?php endwhile;?>
    
    <?php
    }
    add_action('thematic_categoryloop', 'my_categoryloop');

    Without any extra pagination code I get the "older posts" link but every page after 1 is "not found". I also have added WP-pagenavi with no problem, but it did not help the solution.

    Has anyone had success with this?

    Posted 2 years ago #
  2. maybe try declaring the $post variable inside the function?

    function childtheme_override_category_loop() {
    global $post;
    foreach(get_the_category() as $category) {
    $cat = $category->cat_ID; }
    
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        query_posts("paged=$paged&cat=' . $cat . '");
    
    while (have_posts()) : the_post(); ?>
    
          <?php endwhile;?>
    
    <?php
    }

    however, i think that filtering pre_get_posts()
    http://codex.wordpress.org/Custom_Queries#Category_Exclusion

    is the best way to modify a query, and won't monkey w/ pagination.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.