ThemeForest

Custom Post Types, Pagination and 404 not found pages

204 posts Bold WordPress Theme Development
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Interviewed on the Envato Notes blog
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 1 and 9 items
  • Europe
  • Referred between 200 and 499 users
srhnbr says

Hey everyone, just to share something I found out today about custom post types, pagination and 404 not found pages while I was working on my site redesign.

The situation

Putting together a showcase gallery to display how people are using my themes.

I created a custom post type for it and was using a page to loop through and display each entry.

The problem

Using the recomended query for custom post types works ok to display the entries but the pagination refuses to display.

Searching a bit got me similar solutions to this: http://themeforest.net/forums/thread/pagination-issue-for-custom-post-type-in-wordpress-30/28915 and this: http://wordpress.org/support/topic/pagination-with-custom-post-type-getting-a-404?replies=1#post-1616810

this solved the pagination issue BUT clicking on the single entry would land me on a 404 not found page!

The solution

After further searching I found this: http://wordpress.org/support/topic/pagination-with-custom-post-type-listing?replies=23#post-1637753

that shed some light as to the cause: you CAN ’T have a PAGE and a CUSTOM POST TYPE with the same name.

So making sure that the page slug is different to the custom post type rewrite slug solved the issue so I now have my pagination and my single entries working just fine :)

Thought I’d share this with you just in case there’s someone else out there “pulling his hair out” on this!

Cheers!

2 years ago
3624 posts
  • Has been a member for 3-4 years
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
  • Interviewed on the Envato Notes blog
  • Envato Staff
  • Reviewer
  • Community Moderator
  • Author had a Free File of the Month
  • Beta Tester
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 50 and 99 items
  • Venezuela
  • Referred between 1 and 9 users
Ivor says

Thanks a bunch Sarah that solved my issue!!!! 8)

2 years ago
Ivor is a moderator
204 posts Bold WordPress Theme Development
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Interviewed on the Envato Notes blog
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 1 and 9 items
  • Europe
  • Referred between 200 and 499 users
srhnbr says
Thanks a bunch Sarah that solved my issue!!!! 8)

Really? Oh! I’m glad :)

2 years ago
704 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Author had a File in an Envato Bundle
  • Attended a Community Meetup
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 1 and 9 items
  • United States
  • Referred between 10 and 49 users
Parallelus says

Thanks for the tips. I’m also experimenting with custom post types and taxonomies right now. I’m very disappointed in how difficult they are to use. It’s easy enough to enable custom types, but when you start to integrate them into a design and create permalinks, make custom queries, add paging, etc. it’s overly complicated and difficult. I think WordPress has something great here, in theory only, because in practice these are still unrefined features.

Here’s a quick example, if I make a custom taxonomy for a custom post type:

Post type: Products
Taxonomy: Manufacturers

Now I’ll add a product called “Computers” and give it the manufacturers “Dell” and “HP”. If I try and query all products for “Dell” and “HP” it won’t. It requires a complex rewrite of the query to pull 2 or more custom taxonomy items in a single query.

Another issue related to this same problem, if I want to pull just 1 of those taxonomy items, lets say “Dell” then I would query “manufacturers” => “dell”, but I won’t get any output unless I specify “products” as the “post_type”. That shouldn’t matter. It should pull ALL post types using that taxonomy. This makes it impossible to have taxonomies that cross multiple post types and pull dynamically into a page without knowing which post types use that taxonomy and specify them as an array “post_type” => array(“products”, “services”)

2 years ago
1266 posts Chris Robinson
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Author had a File in an Envato Bundle
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
  • Elite Author
  • Bought between 10 and 49 items
  • United States
  • Referred between 200 and 499 users
contempoinc says
It’s easy enough to enable custom types, but when you start to integrate them into a design and create permalinks, make custom queries, add paging, etc. it’s overly complicated and difficult. I think WordPress has something great here, in theory only, because in practice these are still unrefined features.

My upcoming real estate theme makes heavy use of custom post types and taxonomies, and I couldn’t agree more that these features are still in their infancy.

2 years ago
1 post
  • Has been a member for 3-4 years
  • Exclusive Author
  • Bought between 1 and 9 items
  • Europe
goksel says

Thanks for the post Sarah! I left an article about custom posts on my blog. It can help if you want to list your custom post types with ordering, filtering and pagination options : http://geryit.com/blog/2011/03/wordpress-custom-post-types/

1 year ago
1 post
  • Has been a member for 2-3 years
  • Bought between 10 and 49 items
elphinstone says

Thanks for your solution!! Helped me al the way. Happy again :)

6 months ago
by
by
by
by
by