My wordpress site has the following URL structure defined in WP Admin > Permalinks

Custom Structure : /articles/%postname%/

For all my default posts.

I also have the following rule defined within my functions.php file:

add_action('init', 'tdd_add_rewrite_rules');

function tdd_add_rewrite_rules()
  global $wp_rewrite;

  $wp_rewrite->add_rewrite_tag('%price%', '([^/]+)', 'price=');
  $wp_rewrite->add_rewrite_tag('%material%', '([^/]+)', 'material=');

  $wp_rewrite->add_permastruct('prices', '/%material%/%price%', array( 'walk_dirs' => false, 'with_front' => false ));


I pass with_front = false so that these specific links do not contain articles/ in the slug.

Using add_permastruct() correctly now works for the urls that contain a price and material i.e


But now any other post url is resulting in a 404 error. i.e


It seems the add_permastruct() function is overwriting any url with 2 parts to the slug. No matter what they are.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.