post_type_link Filter – Too Few Arguments
I think you just have to do : add_filter( ‘post_type_link’, ‘phone_custom_permalink’, 10, 2 ); To tell the hook that you are passing it 2 arguments.
I think you just have to do : add_filter( ‘post_type_link’, ‘phone_custom_permalink’, 10, 2 ); To tell the hook that you are passing it 2 arguments.
Ok, I found a solution. By default in WP there is an option to filter categories by tags. E.g. https://example.com/category_name?tag=tag_name. I added a rewrite rule and redirection: https://developer.wordpress.org/reference/functions/add_rewrite_rule/ add_action( ‘init’, function () { add_rewrite_rule( ‘([a-z0-9-]+)\/tag\/([a-z0-9-]+)\/?$’, ‘index.php?category_name=$matches[1]&tag=$matches[2]’, ‘top’ ); } ); https://developer.wordpress.org/reference/hooks/template_redirect/ add_action( ‘template_redirect’, function () { if ( is_category() && is_tag() && ! empty( $_GET[‘tag’] … Read more
You need to register a ‘rewrite endpoint’ using add_rewrite_endpoint(): <?php add_action( ‘init’, function() { add_rewrite_endpoint( ‘play’, EP_PERMALINK ); } ); Now, after flushing permalinks, in whatever template or code you’re using for your products you can check this to determine whether the /play version of the URL is being accessed: <?php if ( false !== … Read more
You don’t need to do this. As long as your site URL in Settings is set to mydomain.tld/wordpress you don’t need to include /wordpress in your rewrite rules. If you look at the rewrite_rules option in the wp_options table you’ll see that none of the default rules are using it, because it’s not required.
There’s two separate problems here: You have code that causes an error. That error is exposing information to end users that you don’t want to expose. The problem that’s causing #2 is that you have error printing enabled in a production environment, which is against best practice. Error reporting is controlled by a PHP configuration … Read more
The problem here is that the rewrite rule uses an invalid regular expression. It’s important to run your rewrite rules through a rewrite rule testing plugin to check that it actually matches the URL you want to use. You don’t need to guess the result then refresh on the frontend to test that it works … Read more
Since you want to add something to the end of every post/page rewrite rule, you probably can just add a rewrite endpoint. These are regexes of the form /[endpoint_name](/[optional_extra_stuff])? that are appended to the already generated rules for pages, posts, archives, … You define on which structures you want to add them by setting the … Read more
Sorry guys, this is becoming a habit, but I found a solution, as follows: set rewrite to false in taxonomy registration: register_taxonomy(‘property_type’,array(‘sbproperty’), array( ‘hierarchical’ => true, ‘labels’ => $labels, ‘show_ui’ => true, ‘query_var’ => true, ‘rewrite’ => false )); And create my own rule add_filter(‘rewrite_rules_array’,’wp_insertMyRewriteRules’); add_filter(‘init’,’flushRules’); function flushRules(){ global $wp_rewrite; $wp_rewrite->flush_rules(); } function wp_insertMyRewriteRules($rules) { … Read more
Your first order of business should be updating the links in your imported content so that people aren’t given links to the old URLs in the first place. This should be pretty easy to do with an SQL replace. For your situation, it’d be something along the lines of: UPDATE wp_posts SET post_content = REPLACE(post_content, … Read more
It appears that WordPress cuts off the final / before it starts matching the URL. So make it optional in the regex and it should work: members/.+?/(.+)/?$ If the city and company parts will not contain slashes it could be even more clear to use [^/]+ to match them (“everything up to a slash”). Then … Read more