Remove custom post type slug not working for child pages
This was solved by using the Permalink Setting: Custom Structure of /%post_id%/ Didn’t find this answer anywhere else, so added it in myself.
This was solved by using the Permalink Setting: Custom Structure of /%post_id%/ Didn’t find this answer anywhere else, so added it in myself.
How to restore WP 5.4 behaviour where a numeric string could added to each page URL and parsed as “page” in WP 5.5?
This “exception” would only be required if you are requesting virtual URLs within /folderToExclude, as opposed to physical files. Any requests to physical directories and files are naturally excluded by the standard WordPress directives. RewriteCond %{REQUEST_URI} !^/(folderToExclude/.*)$ # add a trailing slash to /wp-admin RewriteRule ^wp-admin$ wp-admin/ [R=301,L] This condition (RewriteCond directive) won’t do anything … Read more
How do I get WordPress URL rewrites into Sitemap?
Newbie question: no index.php? in my plain wordpress permalink
Quick’n’dirty Class to do this following below (you need to flush by hand in admin settings for permalinks): <?php /** * Add query args & vars & redirect stuff somewhere else * Could be extended to support arrays of query args on input * @package Rewrite Class * @author F.J.Kaiser */ class wpseAddRewriteRules { var … Read more
Ok, so I got it working more or less correctly, although there is still a small problem left, please read on.. Here is what I’ve got: in fucntions.php: Rewrite rules add_action(‘init’, ‘my_rewrite_add_rewrites’); function my_rewrite_add_rewrites(){ add_rewrite_rule( ‘^services/([^/]+)/?$’, ‘index.php?post_type=service&order=ASC&orderby=menu_order’, ‘top’ ); add_rewrite_rule( ‘^services/([^/]+)/page/?([0-9]{1,})/?$’, ‘index.php?post_type=service&paged=$matches[2]&order=ASC&orderby=menu_order’, ‘top’ ); } Redirect rule add_action(“template_redirect”, ‘my_template_redirect’); function my_template_redirect(){ global $wp_query; // if … Read more
Have you tried third parameter as “top” into add_rewrite_rule ? Something like this: add_rewrite_rule($regex, $redirect, ‘top’); And also re-save permalink settings.
Two issues – your rewrite rule isn’t formatted correctly, this: ‘shop-guide/shop-page/id/([^/]*)/’ should be: ‘shop-guide/shop-page/id/([^/]*)/?$’ and if shop-guide and shop-page are parent / child pages, this: ‘index.php?p=143&id=$matches[1]’ should be: ‘index.php?pagename=shop-guide/shop-page&id=$matches[1]’
I have found my answer while searching. Thanks to this answer of @Milo: https://wordpress.stackexchange.com/a/50775/23214 pagename must include the full parent/child path. So, I had to change index.php?pagename=page-b… to index.php?pagename=page-a/page-b…. Changed it and works ok. Here is the Full code: add_filter( ‘query_vars’, ‘wpse26388_query_vars’ ); function wpse26388_query_vars( $query_vars ){ $query_vars[] = ‘var1’; $query_vars[] = ‘var2’; $query_vars[] = … Read more