custom-post-type-permalinks
custom-post-type-permalinks copied to clipboard
404 on single post page
Since version 2.1.0 I'm getting 404s on all of my single post pages for custom post types. My custom post type (wpbb_job) is defined inside another plugin (WP Broadbean) and has a rewrite slug of 'jobs'. Before v2.1.0 I was able to define the permalink as:
http://<domain>/jobs/%wpbb_job_industry%/%postname%/
where wpbb_job_industry
is the taxonomy. This would be transformed into something like this:
http://<domain>/jobs/marketing/digital-marketing/project-manager/
Since v2.1.0 the permalinks are being converted correctly, but clicking on them results in a 404. Previously the correct post would be displayed.
I've narrowed the problem down to Rewrite.php
, in particular where you tidied up the code in the add_hook()
function and removed the add_action( 'wp_loaded', array( $this, 'add_rewrite_rules' ), 10 );
after v2.0.2. I can't work out why this is causing the 404 though.
@sijones-uk have you found any workarounds for this? I tried, but was unsuccessful. For now, are you just using an earlier release?
@danielshields Unfortunately not, so I can't update the plugin for now, It seems to have been the removal of the line add_action( 'wp_loaded', array( $this, 'add_rewrite_rules' ), 10 );
in Rewrite.php
when v2.1.0 was released that broke things. If you want to ensure that the plugin doesn't get accidentally updated you can temporarily change the "Version" in custom-post-type-permalinks.php
to 999. However, that's not a good long-term strategy. I haven't found an alternative plugin that does what I need either.
I've exactly the same issue - thanks @sijones-uk for the tip to fix in the meantime!
@sijones-uk @danielshields @Trenbania Sorry for late reply.
Replace CPTP_Module_Rewrite
use CPTP_set_rewrite_module
filter.
Sample code https://gist.github.com/torounit/86c3c140071d29cd1b2fd2900f23c813.
Thanks @torounit. Will this fix be folded into the master branch?
This seems to be still open with 3.0.0? How can I fix it? My CPT Single is suddenly a 404...
Version 3.1.1 still with this problem. :'( I'm deactivating the plugin until this is fixed on master, so sad.
Review my comment on #79 for my solution with a 404 handler.