Rewrite rule for custom taxonomy

I came up with this with the add_rewrite_rule(): add_rewrite_rule(‘^recipes-with-([^/]*)/?’,’index.php?ingredient=$matches[1]’,’top’); I did some testing for the above, and it works well when you use it for one taxonomy at time. Here is the code from my functions.php: add_action( ‘init’, ‘create_ingredient_tax’ ); function create_ingredient_tax() { register_taxonomy( ‘ingredient’, ‘post’, array( ‘label’ => ‘Ingredient’, ‘hierarchical’ => true ), array( … Read more

How do I remove a word from a url in WordPress using .htaccess?

You can add the following to your .htaccess file in between the <IfModule mod_rewrite.c> tags: RewriteCond %{HTTP_HOST} RewriteRule ^our-focus/(.*)$ /focus/$1 [R=301,L] Your .htaccess should looks like the following: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # Custom Rewrite RewriteCond … Read more

Multiple endpoints in one URL

Not sure of the context for this, is it a custom post type or just a page? This might be something which you’re looking for – function add_lead_management_endpoints() { add_rewrite_rule( ‘manage-lead/lead_id/([0-9]{1,})/product_id/([0-9]{1,})’, ‘index.php?pagename=manage-lead&lead_id=$matches[1]&product_id=$matches[2]’, ‘top’ ); add_rewrite_tag( ‘%lead_id%’, ‘([^&]+)’ ); add_rewrite_tag( ‘%product_id%’, ‘([^&]+)’ ); } add_action( ‘init’, ‘add_lead_management_endpoints’ ); You’ll need to flush permalinks for this to … Read more

Taxonomy rewrite question

Your permalink structure for taxonomy will conflict with default one for pages. In the case of the address domain.com/item-one/item-two how does WordPress know if it’s a page item-two with the parent page item-one or item-two is custom post type and item-one is term of region taxonomy? The order of rewrite rules will decide, and because … Read more

Custom post type permalink changing itself every other change

BETTER SOLUTION Actually, there is a note on the WP_Query reference: Note: Ticket #18408 For querying posts in the admin, consider using get_posts() as wp_reset_postdata() might not behave as expected. So instead of attempting to reset the global post data, the more proper solution is either: Use get_posts(): $seriesPosts = get_posts($args); foreach($seriesPosts as $p){ $select … Read more