• Resolved johnfrancisco

    (@johnfrancisco)


    Hi.

    I use Custom Post Type to list projects on Home page.
    My template home page loop is :

    [Code moderated as per the Forum Rules. Please use the pastebin]

    I use Custom Post Type UI plugin to register the custom post type.
    Permalinks are set like this : /archives/%post_id%

    The “older projects” link correcly displays on home page but links to nothing :
    https://mywebsite/page/2

    I know that It should be https://mywebsite/my_home_page_slug/page/2 to work properly but I don’t know how to set this up on home page.

    Any help would be great.
    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter johnfrancisco

    (@johnfrancisco)

    My template home page loop is here :
    https://pastebin.com/HLAJC8wi

    Thread Starter johnfrancisco

    (@johnfrancisco)

    Hi

    I have no solutions yet.

    I explain again with another precisions:

    I use Custom Post Type to list projects.
    I use “Custom Post Type UI” plugin to register the custom post type.
    Permalinks are set like this : /archives/%post_id%
    I set in wordpress a “Portfolio” page as the front page and another page for the Blog.
    So the Portfolio page is the front_page and the Blog page is the home. (I had confirmed this by checking with is_home(); and is_front_page(); conditional tags.

    So my template loop is fine, I test it on another page and it works fine but it does not work on the front page for the reason I exposed on first post.

    The “older entries” link correctly displays on my Portfolio front page but links to nothing :
    https://mywebsite/page/2

    The reason is that It should be https://mywebsite/my_front_page_slug/page/2 to work properly, but the slug of the front_page does not appear.

    So to solve this issue, I need a way to put the slug of the static front_page (here “portfolio”) to the link generated by next_posts_link(); template tag only on this specific page.

    Hope that makes sense.

    Thanks.

    Thread Starter johnfrancisco

    (@johnfrancisco)

    Found the fix here.
    It works great for me.

    so just add this as paged param of your loop :

    if ( get_query_var('paged') ) {
        $paged = get_query_var('paged');
    } else if ( get_query_var('page') ) {
        $paged = get_query_var('page');
    } else {
        $paged = 1;
    }
    query_posts( array( 'post_type' => 'post', 'paged' => $paged ) );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Pagination for Custom Post Types on Home Page’ is closed to new replies.