Rewrite URL – how to do a SEO-friendly Unicode custom URL?

If you write your post titles in Bānglā but set the post slug in English, you can do this: function wpse117090_pre_post_link( $permalink, $post ) { return str_replace( ‘%posttitle%’, sanitize_title( $post->post_title ), $permalink ); } add_filter( ‘pre_post_link’, ‘wpse117090_pre_post_link’, 10, 2 ); Then change your permalink structure to, for example, /%postname%/%posttitle%/ (Please note that the above code … Read more

generate_rewrite_rules (action) vs add_rewrite_rule (function): which one is preferred?

They are totally differents: generate_rewrite_rules is an action hook and add_rewrite_rule is a function. That said, use add_rewrite_rule() if you want to define custom rewrite rules. Use generate_rewrite_rules to perform an action (from codex) “after all rewrite rules have been created”. That doesn’t mean that you can not add rewrite rules via generate_rewrite_rules, in fact … Read more

Unique URL Every Time

You could use a partial implementation of JWTs to pass a unique token including identifying information and the requested post ID (or slug) as the endpoint, and check the identifying info upon validation. URLs containing a unique token can be rewritten to pass the token as a specific variable. A ‘parse_query’ action hook can then … Read more

Custom Permalinks for Blog Posts Only

Even though this is no longer a problem for you, I decided to pursue it for purely academic reasons. I got it working by prepending rewrite rules and filtering permalinks. Note that I wouldn’t actually recommend doing this, but it’s fun to know it’s possible 🙂 function filter_post_link($permalink, $post) { if ($post->post_type != ‘post’) return … Read more

Use subdomain for certain urls

Try this (untested): # BEGIN Forums Rewrite RewriteCond %{HTTP_HOST} !^www\.domain.com RewriteCond %{HTTP_HOST} ([^.]+)\.domain.com RewriteRule ^(.*)$ forums/%1 # END Forums Rewrite It should work with both your requirements. You don’t need the second one (rewriting the forums folder to subdomain) because rewriting the actual forum ID will override the basic subdomain rewriting forums.domain.com/forumid=16. You should add … Read more

Multiple endpoints to same page

Okay… here’s how you add the rule. <?php add_action(‘init’, ‘add_my_rule’); function add_my_rule() { add_rewrite_rule(‘^test\/link.*$’,’index.php?pagename=about’,’top’); } ?> This rule will ensure that when you visit a url like http://…/test/link or http://…/test/link<xyz>, you are redirected to the about page (please make sure the slug for about page is ‘about’). Also, http://…/test/, will take you the test page … Read more

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