Meta_Query as a way how to setup CPT permalinks – is it a good thing?

Since it is a performance question, you might be able to avoid using meta keys at all by storing/getting that data another way and not having to set a separate meta field to match with… a. You could get the year from the published $post->post_date… So that when doing the query just use the date … 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

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