How do I add a tag slug to a category URL to filter posts?

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

Create page (not the post type) dynamically

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

Get wordpress installation folder

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.

How can i ensure that SQL statements are not displayed if an enduser types the wrong variable name in the URL

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

My bbPress rewrite rules aren’t working

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

Custom URL rewrites for templates

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

Permalink Problems

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

Url rewrite with htaccess

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