WordPress custom permalink and archive link for custom post type

You need to either go into Settings -> Permalinks and click Save Or if you’re doing this programmatically you need to use flush_rewrite_rules(), but make sure this is only used when you activate/deactivate the plugin, DON’T set this in code that runs (like in init, or on every page load): https://developer.wordpress.org/reference/functions/flush_rewrite_rules/ register_deactivation_hook( __FILE__, ‘flush_rewrite_rules’ ); … 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

Custom rewrite rule not working

Hope this will work out for as it did for me. add_filter(‘rewrite_rules_array’, ‘insert_custom_rules’); add_filter(‘query_vars’, ‘insert_custom_vars’); function insert_custom_vars($vars){ $vars[] = ‘main_page’; return $vars; } function insert_custom_rules($rules) { $newrules = array(); $newrules=array( ‘page-name/(.+)/?’ => ‘index.php?pagename=page-name&main_page=$matches[1]’ ); return $newrules + $rules; } So, with the help of get_query_var() function, we can get value from url and use accordingly. … Read more

WordPress simple Url Rewrite

Theme’s functions.php is not the best place to do these sort of URL rewrites. Why?: because in that case WordPress will be fully loaded and then redirected to a new link and then fully loaded again to show the page. That’s a lot of delay for a page view. Instead of that, you may use … Read more

Rewrite Rules not redirecting rewrite

Ok managed to figure this out, instead of adding action for a rewrite. Because what I was wanting to rewrite was a taxonomy i should have been using something like this : ‘rewrite’ => array(‘slug’ => ‘listings/make’, ‘product_make_model’ => false) When registering the taxonomy, which basically rewrites the slug as the taxomomy is created/registered. Works … Read more

One off rewrite for single post-type slug (show normal page with same URL instead)

I installed Monkeyman Rewrite Analyzer https://wordpress.org/support/plugin/monkeyman-rewrite-analyzer/ which helped a great deal. I saw this referenced on Jan Fabry’s detailed answer on this post which also helped me. First thing that I found out with the plugin was that my rewrites weren’t actually getting added; they didn’t appear in the logic. It turns out the add_rewrite_rule() … Read more

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