WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type Archives
paging problem with yearly/monthly archives (6 posts)

  1. pbsrg
    Member
    Posted 2 years ago #

    Great plugin!! Hadn't noticed any issues at all until recently...

    I have the archives for a custom post type set for the yearly type. The first page of the archive works fine (/post-type-slug/2011/), but when I click the "Older Posts" button I get a 404 error (/post-type-slug/2011/page/2/). I have this problem with all my custom post type archives, but not with the default WordPress blog archives.

    Any suggestions?

    I am using version 1.5.1 of the Plugin.

    Thank you

    http://wordpress.org/extend/plugins/custom-post-type-archives/

  2. pbsrg
    Member
    Posted 2 years ago #

    I should also clarify that paging is also working for the main archive (/post-type-slug/page/2/). It's only the yearly and monthly archives where I have the problem.

    Thanks!

  3. onetrev
    Member
    Posted 2 years ago #

    Exact same problem here. Unfortunately I can't provide any help at this time, hopefully someone will...

  4. blabbr
    Member
    Posted 2 years ago #

    Hey the two of you!

    i experienced the exactly same problem.
    The problem seems to be that as soon as you have paged monthly or yearly archives, the plugin isn't able to handle that.

    i had a look at the code and found this fix:

    IN THE FOLDER custom-post-type-archives IN THE FILE post-type-archives.php LOCATE THIS CODE:

    $custom_rules["$url_base($post_type)/([0-9]+)/([0-9]{1,2})/([0-9]{1,2})/?$"] = // enable listing by day
    				"index.php?post_type_index=1&post_type=$post_type_slug&year=" . $wp_rewrite->preg_index(2) . '&monthnum=' . $wp_rewrite->preg_index(3) . '&day=' . $wp_rewrite->preg_index(4);
    			$custom_rules["$url_base($post_type)/([0-9]+)/([0-9]{1,2})/?$"] = // enabled listing by month
    				"index.php?post_type_index=1&post_type=$post_type_slug&year=" . $wp_rewrite->preg_index(2) . '&monthnum=' . $wp_rewrite->preg_index(3);
    			$custom_rules["$url_base($post_type)/([0-9]+/?$)"] = // enable listing by year
    				"index.php?post_type_index=1&post_type=$post_type_slug&year=" . $wp_rewrite->preg_index(2);

    AND REPLACE ALL OF IT WITH THIS CODE

    $custom_rules["$url_base($post_type)/([0-9]{1,4})/([0-9]{1,2})/([0-9]{1,2})/page/([0-9]{1,})/?$"] = // ### FIX: enable listing by day + paging
    				"index.php?post_type_index=1&post_type=$post_type_slug&year=" . $wp_rewrite->preg_index(2) . '&monthnum=' . $wp_rewrite->preg_index(3) . '&day=' . $wp_rewrite->preg_index(4) . "&paged=" . $wp_rewrite->preg_index(5);
    			$custom_rules["$url_base($post_type)/([0-9]{1,4})/([0-9]{1,2})/([0-9]{1,2})/?$"] = // enable listing by day
    				"index.php?post_type_index=1&post_type=$post_type_slug&year=" . $wp_rewrite->preg_index(2) . '&monthnum=' . $wp_rewrite->preg_index(3) . '&day=' . $wp_rewrite->preg_index(4);
    			$custom_rules["$url_base($post_type)/([0-9]{1,4})/([0-9]{1,2})/page/([0-9]{1,})/?$"] = // ### FIX: enable listing by month + paging
    				"index.php?post_type_index=1&post_type=$post_type_slug&year=" . $wp_rewrite->preg_index(2) . '&monthnum=' . $wp_rewrite->preg_index(3) . "&paged=" . $wp_rewrite->preg_index(4);
    			$custom_rules["$url_base($post_type)/([0-9]{1,4})/([0-9]{1,2})/?$"] = // enabled listing by month
    				"index.php?post_type_index=1&post_type=$post_type_slug&year=" . $wp_rewrite->preg_index(2) . '&monthnum=' . $wp_rewrite->preg_index(3);
    			$custom_rules["$url_base($post_type)/([0-9]{1,4})/page/([0-9]{1,})/?$"] = // ### FIX: enable listing by year + paging
    				"index.php?post_type_index=1&post_type=$post_type_slug&year=" . $wp_rewrite->preg_index(2) . "&paged=" . $wp_rewrite->preg_index(3);
    			$custom_rules["$url_base($post_type)/([0-9]{1,4})/?$"] = // enable listing by year
    				"index.php?post_type_index=1&post_type=$post_type_slug&year=" . $wp_rewrite->preg_index(2);

    NOW NOTE THIS:
    - after doing this you have to update your permalinks
    - i don't give you a guarantee that this will work - it won't break something major though :-)
    - only works if you use rewrite slugs from the plugin's options (haven't looked into not using slugs...)
    - brought to you by http://www.kition.net ;-)
    - i've only tested it for the yearly archives because i don't have monthly or daily archives big enough to be paginated (and i don't feel like creating some pages right now...)

    hope it works for you guys! if not, drop a line, i might be able to help out...

    cheers, phil

  5. pbsrg
    Member
    Posted 2 years ago #

    This fix worked for us!

    Thank you blabbr!

  6. supersuphot
    Member
    Posted 2 years ago #

    Cool thanks! blabbr

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic