Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using plugin break nested pages #41

Open
athlan opened this issue Nov 21, 2018 · 6 comments
Open

Using plugin break nested pages #41

athlan opened this issue Nov 21, 2018 · 6 comments
Assignees
Labels

Comments

@athlan
Copy link
Owner

athlan commented Nov 21, 2018

Followup from issue athlan/acf-permalink#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?

@athlan
Copy link
Owner Author

athlan commented Nov 21, 2018

@SebKay I've recreated an issue in automated tests: #42

Will investigate it.

@athlan
Copy link
Owner Author

athlan commented Nov 23, 2018

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

@athlan
Copy link
Owner Author

athlan commented Nov 23, 2018

Well, I have some workaround (link #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).

@athlan athlan added bug and removed investigation labels Nov 23, 2018
@SebKay
Copy link

SebKay commented Nov 26, 2018

@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.

@athlan
Copy link
Owner Author

athlan commented Nov 26, 2018

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.

@SebKay
Copy link

SebKay commented Nov 27, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants