Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #13340

    On http://kellyalexandershow.com we are using the shoutbox theme. On the front page we are displaying both ‘posts’ and ‘episodes’ (a custom post type) which I implemented by placing the following line in index.php, replacing the original setup for a new query:

    $avia_config = array( “post_type” => ‘episode’+’post’, “paged” => get_query_var( ‘paged’ ), “posts_per_page”=> $postcount, “tag” => ‘homepage’);

    As expected, this pulls up several (10 or more) pages of posts from the two post types. Going to page two produces the next page. Going to page 3 or any higher page produces 404.

    Both the Podcasts page, which shows ‘episodes’, and the Blog page, which shows ‘posts’, work fine for all pages. I created a template for the podcasts, based on the blog template.

    I have tried the plain default permalinks, our preference which is category/post, and simple post name, and they all produce the same result. I also tried plugging a page number into the query setup, instead of “paged” => get_query_var( ‘paged’ ) I tried paged” => ‘3’, and that pulled up the appropriate set of posts and made the right page number show at the bottom. So the issue seems to be that ‘paged’ isn’t getting set properly before my code in index.php is invoked…I think.

    Thanks for this interesting theme; I’ve had to learn a bit more than I wanted to about how it works though ;)

    #78844

    Any thoughts on this? Client is pushing for solution yesterday

    #78845

    Hi ayu56,

    The only thing I found with some google-fu is trying to use ‘page’ instead of ‘paged’. Seems to be related to the difference in a query on the index vs other pages.

    Regards,

    Devin

    #78846

    Unfortunately that was one of the many things I tried before posting the problem. The index is the only one that is fetching both posts and ‘episodes’ and I think that is related. I suspect that something (that I haven’t found) is looking at the number of pages for ‘posts’ instead of the number of pages for ‘posts’+’episodes’, and therefore thinking that the page is out of range when it is not. Probably something BEFORE I set up the query is computing the max page based on ‘posts’ alone and setting an error condition.

    If you can point me to the code that is actually computing the ‘paged’ variable, before it ever gets to my index.php, I can probably fix this.

    FYI I tried the ‘views’ plugin, and it is able to properly paginate a composite query. However, I didn’t come up with a way to integrate that with the shoutbox theme and my client really likes the visuals of shoutbox so I dropped that approach.

    #78847

    The pagination code itself can be found in function-set-avia-frontend.php. I’m not sure it will help however but you might want to try changing the settings in wordpress for Static front page vs. default. Maybe try changing your permalinks settings to default as well if they are not already.

    Regards,

    Devin

    #78848

    Thanks I’ll try both and also look at the code.

    #78849

    Feel free to post your changes/results/fixes :)

    #78850

    I finally made it work!

    Here’s what I did:

    1. create new page template for home page

    2. create new page called home with permalink /main and using the new template

    3. edit the function-set-avia-frontend.php file to detect the home page and insert /main into the pagination links.

    Notes:

    –The new page template, template-home.php, has my query hardcoded:

    $avia_config = array( “post_type” => ‘episode’+’post’, “paged” => get_query_var( ‘paged’ ), “posts_per_page”=> $postcount, “tag” => ‘homepage’);

    –in function-set-avia-frontend.php the following changes were made:

    1. all calls to get_pagenum_link() were replaced with calls to special_get_pagenum_link()

    2. here is the text of the new function:

    if(!function_exists(‘special_get_pagenum_link’))

    {

    /**

    * This function serves to fix problem with pagenum greater than two from homepage when complex query

    */

    function special_get_pagenum_link ($pagenum = 1, $escape = true)

    {

    $homepage = get_bloginfo(‘url’).’/';

    $curbase = get_pagenum_link (‘1′, $escape);

    $result = get_pagenum_link ($pagenum, $escape);

    /* echo ‘curbase ‘,$curbase,’ homepage ‘,$homepage;*/

    if (!($curbase == $homepage)) return $result;

    $result = str_ireplace($homepage, $homepage.’main/’, $result);

    return $result;

    }

    }

    This is a bit of a kluge but it gets the desired result. I’d be glad to see any feedback on it. I never did figure out why the real links would not work; I just forced the pagination to go to something that would be found.

    Thanks for your help.

    #78851

    Glad you found a way to make it work and thank you for posting your final results :)

    Regards,

    Devin

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

The topic ‘404 on pages greater than 2 from front page’ is closed to new replies.