Custom post type permalink structure incorporating category name
Custom post type permalink structure incorporating category name
Custom post type permalink structure incorporating category name
you have a little error in the call of add_rewrite_rule with an extra slash before index.php. with this correction, your system works without a CPT like data. you can try that : add_action(‘init’, function () { add_rewrite_rule( ‘^data/([a-z0-9-]+)/([a-z0-9-]+)/([a-z0-9-]+)/?$’, ‘index.php?data_type=$matches[1]&data_action=$matches[2]&data_post_id=$matches[3]’, ‘top’ ); }); add_action(“template_redirect”, function () { $data = []; foreach ([“data_type”, “data_action”, “data_post_id”] as $key) … Read more
301 Redirect via rewrite_rules_array (not .HTACCESS)
Part 1 Ans: I am presuming you have added the custom post type yourself, in which case it is easy. When you register a new post type, you can set any rewrite rules for that post type to follow as part of the arguments used in the register_post_type( ‘name’, $args ) function. If your post … Read more
Rewrite rule leads to 404
How to add “page/” prefix to standard WP static pages?
There are 2 possible ways to fix the issue with the term’s permalinks (which is currently using the wrong query var name – intvn-cat): Easy. Just set the 3rd parameter for add_rewrite_tag() to intervention_cat=. I.e. add_rewrite_tag( ‘%intvn-cat%’, ‘(.+)’, ‘intervention_cat=” ); This is what I would actually do – Remove the add_rewrite_tag() part in your code, … Read more
I dont know how I missed out on that while looking for aproaches, but I have a working solution now based on this answer. I modified it to check for slashes in $query->request, if there is none I first look for my custom post type (get_posts() with’slug’ => $query->request). If no post is found I … Read more
Resolved! So I’ve added rewrite rule: add_rewrite_rule( ‘^[^\/]*\/review\/([^\/]*)$’, ‘index.php?review=$matches[1]’, ‘top’ ); And additional code to create appropriate url structure: function rev_update_slug( $post_link, $post, $leavename ) { if ( ‘review’ != $post->post_type || ‘publish’ != $post->post_status ) { return $post_link; } //** Field where related page post object stored in ACF field **// $pageid= get_field(‘related_home_inner_page’,$post->ID); $post_link … Read more
How to Dynamically Change the author_base URL Slug by Language in WordPress?