Pagination on Custom Post Type Tag archive page not working
-
I have a problem with a Custom Post Type (products) that also uses the default taxonomies Categories and Post tags.
I’m using archive-products.php as an archive template for the products, that works great. When it comes to Tag or Category filtering I’m using archive.php. I could use tag.php or category.php as well, the error and result is the same.
When on the archive-products.php page all the products are listed and paginated with 6 per page. When a tag is clicked like women then the archive.php template serves up the tag with a url of tag/women, totally normal and expected.
Here are resulting queries:
[ WP_Tax_Query->_transform_terms ] SELECT wp_term_taxonomy.term_taxonomy_id FROM wp_term_taxonomy INNER JOIN wp_terms USING (term_id) WHERE taxonomy = 'post_tag' AND wp_terms.slug IN ('women') [ get_term_by ] SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'post_tag' AND t.slug = 'women' LIMIT 1 [ WP_Query->get_posts ] SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (19) ) AND wp_posts.post_type IN ('products', 'services', 'post') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order, wp_posts.post_date DESC LIMIT 0, 6
To pull the results from the products, services, and post Post Types i’m using:
http://pastebin.com/eUrpCFQCThe page shows the first 6 products tagged with women. When you click to go to the next page,
/tag/women/page/2/
the problem happens. I get a 404 Not Found. The 404 page is returned, not even the archive.php page.The resulting queries are:
[ WP_Tax_Query->_transform_terms ] SELECT wp_term_taxonomy.term_taxonomy_id FROM wp_term_taxonomy INNER JOIN wp_terms USING (term_id) WHERE taxonomy = 'post_tag' AND wp_terms.slug IN ('women') [ get_term_by ] SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'post_tag' AND t.slug = 'women' LIMIT 1 [ WP_Query->get_posts ] SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (19) ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order, wp_posts.post_date DESC LIMIT 6, 6
The tag (women) is still pulled from the url except the third query has ignored the products, services and posts array_merge into
$wp_query
. Instead it reverts to trying to simply pull from post. i.e. wp_posts.post_type = ‘post’ vs. wp_posts.post_type IN (‘products’, ‘services’, ‘post’)The result is a 404 response since no Posts have the women tag assigned to them. I’ve tried just about everything I can think of.
Anybody else experience this or have suggestions?
- The topic ‘Pagination on Custom Post Type Tag archive page not working’ is closed to new replies.