Can’t add external rewrites

First off, don’t ever do this: add_action(‘init’, ‘flush_rewrite_rules’); Every time WordPress loads, you are going to flush the rewrite rules. You only need to do this once to make sure your rewrite shows up. Second, add_rewrite_tag only takes two arguments, the tag and the regex. If you want to specify a query variable directly, you’ll … Read more

How to set up Author archives with sub category URL

As I mentioned in my comment, you can use add_rewrite_endpoint to accomplish this. First, add the endpoint: function wpa_author_endpoints(){ add_rewrite_endpoint( ‘liked-posts’, EP_AUTHORS ); } add_action( ‘init’, ‘wpa_author_endpoints’ ); After flushing rewrite rules (visit your Settings > Permalinks page in admin), author URLs can now be appended with /liked-posts/. Next, add a filter to author_template to … Read more

Best way to redirect site in subdirectory to root?

The only way I managed to get this to work was with the following in the .htaccess of the /site/ directory: RewriteBase \ RedirectMatch 301 ^/site/$ /$1 RedirectMatch 301 ^/site/(?!wp-admin/|wp-content/|wp-includes/)(.*)$ /$1 Whilst I am aware that RewriteRule ^site/ /$1 [R=301,NC,L] should have worked, and that RewriteRule ^site/(.*)$ /$1 [R=301,NC,L] should have also worked (according to … Read more

add_rewrite_endpoint not working

Your code should (and does from quick check) work in principle. You should not be flushing permalink every page load, just once. Use rewrite helper like Monkeyman Rewrite Analyzer to see if rules are being generated, what they are, and how are they matching to real URLs in your site.

add_rewrite_rule isnt working, not getting added to rules array, why?

Try this. You also don’t want to include $wp_rewrite->flush_rules() inside your function as that would flush on every page load. add_action(‘rewrite_rules_array’, ‘new_rewrite_rules’); function new_rewrite_rules($rules){ $newrules = array(); $newrules[ ‘^lists/([^/]*)/([^/]*)/?’ = ‘index.php?lists=$matches[1]&post=$matches[2]’; return $newrules + $rules; } If you want to flush the rules only once then try this: add_action(‘init’, ‘flush_new_rule’); function flush_new_rule(){ global $wp_rewrite; if(is_array(get_option(‘rewrite_rules’)) … Read more

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