Custom post type permalink: only use %post_id% and remove %postname%

I found the answer myself – so here is the update to above problem: Custom post type registration: function create_post_type_mycustomname() { $args = array( ‘capability_type’ => ‘post’, ‘has_archive’ => ‘mycustomname’, ‘rewrite’ => array( ‘slug’ => ‘/mycustomname’, ‘feeds’ => false ) ); register_post_type(‘ctp_mycustomname’, $args); } add_action(‘init’, ‘create_post_type_mycustomname’); Change the links: function mycustomname_links($post_link, $post = 0) { … 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

Custom Post Type and Taxonomy URL rewrite

I have used my jewelery post type bellows code, You can just replace your post type & taxonomy. Just copy & paste on your functions file. <?php //Register a Jewelry post type. function jewelry_post_register() { $labels = array( ‘name’ => _x( ‘Jewelries’, ‘post type general name’, ‘twentytwelve’ ), ‘singular_name’ => _x( ‘Jewelry’, ‘post type singular … Read more

How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy

After adding print_r($wp_query); to my template and examining the results, I have discovered URL formats that work. I wrote, in my question, that the following format doesn’t work — in fact, it does – if you spell your custom taxonomy name correctly. example.com/?ctxname=term1+term2 Pretty URLs with the ‘+’ and ‘,’ operators (indicating AND and OR … 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