Forums

[resolved] Custom Post Type List Page (7 posts)

  1. wildekyote
    Member
    Posted 9 months ago #

    I'm drawing a blank on how to get this to work right and am hoping someone can point me in the right direction. I have a custom post type that I have created and populated. All is fine with accessing the individual posts and the archive page. I want to create a separate navigation link to a list page that resembles the output and functionality of the main index page only it is displaying the new post type and not posts. As an attempt to do this I copied the index.php into a new template page changed the query_posts( 'post_type=newPostType') and applied the template to a new page. The page loads up nice with the first 10 of the post type but next_post_link and prev_post_link don't operate and I cant get beyond page one. Anyone got the correct way of doing this? The archive page isn't quite what I need since it's more excepts and no images etc. and I don't want to alter the archive for normal posts. an help is appreciated. Thanks

  2. Big Bagel
    Member
    Posted 9 months ago #

    I've never done this myself so I'm wary of giving any specific advice, but I think this link shows what you're after.

    Edit:
    Hrm...That link is a little old; I think there's an easier way. Try adding:

    'paged=' . get_query_var( 'page' )

    to your query arguments.

  3. wildekyote
    Member
    Posted 9 months ago #

    Thanks. I had seen that page as well but no luck. After further research it looks like I'm getting the pagination correctly to some degree I get 3 pages which would be correct but the posts listed on the page aren't changing.

    For now it's no longer an issue for me since the site owner wants the all listing on one long page so that's an easy fix but I'm still going to pursue the proper way to handle this.

  4. Big Bagel
    Member
    Posted 9 months ago #

    Mokay. Did you try adding the paged argument to your query_posts call? For example:

    query_posts( 'post_type=newPostType&paged=' . get_query_var( 'page' ) );

    According to the codex on WP_Query that should do the trick.

  5. wildekyote
    Member
    Posted 9 months ago #

    Yes I did try that and I think that may be what is giving me the right pages now but it still shows only the first 10 records no matter what page I'm on. I'm sure there is probably a better way to do this than a template applied to a blank page. Just seems a little rigged. If I come across the issue I'll post what it was.

  6. Big Bagel
    Member
    Posted 9 months ago #

    Recently helped someone who had the same problem here. Using "paged" instead of "page" worked:

    query_posts( 'post_type=newPostType&paged=' . get_query_var( 'paged' ) );

  7. wildekyote
    Member
    Posted 9 months ago #

    Perfect!! Thank you so much. Worked exactly as I was hoping.

Reply

You must log in to post.

About this Topic