Support » Developing with WordPress » Custom permalinks

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m not sure I follow. The dynamic URL element should relate to what is now passed as id=6, and it’s not an actual child page? The thing is, WP will assume it’s a child page anyway and the request will 404 if there is not an actual child page with that name. You can pass custom values as URL elements by adding rewrite rules, but the rewrite rule needs to match a static element so that the request can be differentiated from a child page request. If your URL was
    example.com/page-1/foo/dynamic-element/
    Where “foo” is static and indicates the next element is dynamic data and not a child page, then it’ll be compatible with the default WP rules. Provided your rule gets tested before the default by it being placed on top of the default rules.
    https://developer.wordpress.org/reference/functions/add_rewrite_rule/

Viewing 1 replies (of 1 total)
  • The topic ‘Custom permalinks’ is closed to new replies.