wordpress-custom-fields-permalink-plugin
wordpress-custom-fields-permalink-plugin copied to clipboard
Using plugin break nested pages
Followup from issue https://github.com/athlan/acf-permalink/issues/12 created by @SebKay.
Hi,
This plugin works perfectly with the custom fields for posts and custom post types, however, there's what seems to be a bug where nested pages go to a 404 when this plugin is active.
Any ideas why this might be?
@SebKay I've recreated an issue in automated tests: https://github.com/athlan/wordpress-custom-fields-permalink-plugin/pull/42
Will investigate it.
The first spot of investigation is that in case of permalink rule /%field_custom_field_params%/%postname%/ plugin cannot distinguish real attempt to query post with particular meta field value or nested page.
Debug: (disabled plugin)
array (size=8)
'WORDPRESS_CUSTOM_FIELDS_PERMALINK_PLUGIN_VERSION' => null
'extra_query_vars' =>
array (size=0)
empty
'query_vars' =>
array (size=2)
'page' => string '' (length=0)
'pagename' => string 'parent-page-2/child-page' (length=24)
'query_string' => string 'pagename=parent-page-2%2Fchild-page' (length=35)
'request' => string 'parent-page-2/child-page' (length=24)
'matched_rule' => string '(.?.+?)(?:/([0-9]+))?/?$' (length=24)
'matched_query' => string 'pagename=parent-page-2%2Fchild-page&page=' (length=41)
'did_permalink' => boolean true
vs (enabled plugin)
array (size=8)
'WORDPRESS_CUSTOM_FIELDS_PERMALINK_PLUGIN_VERSION' => string '1.5.0' (length=5)
'extra_query_vars' =>
array (size=0)
empty
'query_vars' =>
array (size=3)
'page' => string '' (length=0)
'name' => string 'child-page' (length=10)
'custom_field_params' =>
array (size=1)
'custom1' => string 'parent-page-2' (length=13)
'query_string' => string 'name=child-page&' (length=16)
'request' => string 'parent-page-2/child-page' (length=24)
'matched_rule' => string '([^/]+)/([^/]+)(?:/([0-9]+))?/?$' (length=32)
'matched_query' => string 'custom_field_params%5Bcustom1%5D=parent-page-2&name=child-page&page=' (length=68)
'did_permalink' => boolean true
Well, I have some workaround (link https://github.com/athlan/wordpress-custom-fields-permalink-plugin/pull/42, see WP_Request_Processor_Rewrite_Chain), little bit hacky, because if some rewrite rules raises 404 (WP only considers first rule) then second round is ran and seems to work.
However I cannot prove that by automated tests.
@SebKay Please confirm if you cannot put pots or pages under another URL (for example 1. setting up different permalink for posts, or 2. using custom post type with prefixed url).
@SebKay Please confirm if you cannot put pots or pages under another URL (for example 1. setting up different permalink for posts, or 2. using custom post type with prefixed url).
The posts and custom post types are working fine, whether they have a custom field prefix or not. It's only becoming an issue when pages are nested within each other.
What about putting posts into subpath like having permalink structure like /some_subpath/%field_ph_post_format%/%postname%/?
It could be simple workaround for now.
I will give this a try and report back!