Rewrite rules for short URL

There are two types of rewrite rules you can generate via the API and add_rewrite_rule: internal rules and external rules. External rules get inserted into your .htaccess file, and must be in a format that can be parsed by Apache’s mod_rewrite. Internal rules get added to the WordPress internal rewrite rule array and must be … Read more

WordPress rewrite does not work for some reason

I am new to WordPress rewrites, so after some StackExchange reading i have figured it out. All rewrites should be passed to index.php, then i can call the page that i want to redirect to, like this: function custom_rewrite_basic() { add_rewrite_rule( ‘validate_data.php’, ‘index.php?pagename=validate-data’, ‘top’ ); } add_action( ‘init’, ‘custom_rewrite_basic’ ); In addition i wanted to … Read more

WordPress add_rewrite_rule second argument not working

on the rewrite flush, the rewrite rule created by the custom post type overwrite yours because the target is the same. to avoid this, you can use this filter const TAXONOMY_PUBLICACOES = “publicacoes”; add_filter(TAXONOMY_PUBLICACOES . “_rewrite_rules”, function ($rules) { unset($rules[“publicacoes/(.+?)/page/?([0-9]{1,})/?$”]); return $rules; });

custom permalink for single post category

In the pl_custom_rewrite_rules() function, change the REGEX pattern to ^new_slug/(.*)$ as in: add_rewrite_rule( ‘^new_slug/(.*)$’, ‘index.php?name=$matches[1]’, ‘top’ ); because WordPress strips the preceeding / from the request path (WP::$request), so using the ^/new_slug never evaluates to true. Additionally, in the pl_custom_permalink() function, remove the global $post; line because the function already receiving the proper post data … Read more

add_rewrite_rule() not stored (I think)

It’s not showing up because internal rewrites must point to index.php. This isn’t your theme’s index.php file, it’s the main root WordPress bootstrap file. This is how WP detects what should be an internal rule (parsed in PHP) and an external rule (added to htaccess). The other issue you will have is that page_name isn’t … Read more

WooCommerce – Conditional for page created by rewrite_rule

In WordPress, the request path, e.g. path/to/something as in example.com/path/to/something?query=string&if=any, is saved in WP::$request which is accessible via the global $wp variable, so in your case, you can do so to check if the page is /dashboard/products: global $wp; // Note: No trailing slashes. $is_my_page = ( ‘dashboard/products’ === $wp->request ); // Or without the … Read more

Rewrite Rule for Post Meta

Okay! So I got this working by just changing the rewrite_rule to include the event… function aca_award_cat_rewrite_rule() { add_rewrite_rule( ‘^awards/([^/]*)/award-category/([^/]*)/?’, ‘index.php?competition=$matches[1]&award_category=$matches[2]’, ‘top’ ); }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)