Skip to main content
edited body
Source Link
Milo
  • 78.8k
  • 4
  • 127
  • 168

Setting has_archive to true causes WordPress to generate a rewrite rule for the archive using the rewrite slug, which is not what you want in your case. Instead, explicitly specify the archive slug as a string and the correct rules will be generated:

$args = array(
    'has_archive'   => 'courses',
    'rewrite'       => array('slug' => 'courses/%course-type%','with_front' => false),
    // the rest oof fyouryour args...
);
register_post_type( 'courses', $args );

Setting has_archive to true causes WordPress to generate a rewrite rule for the archive using the rewrite slug, which is not what you want in your case. Instead, explicitly specify the archive slug as a string and the correct rules will be generated:

$args = array(
    'has_archive'   => 'courses',
    'rewrite'       => array('slug' => 'courses/%course-type%','with_front' => false),
    // the rest o fyour args...
);
register_post_type( 'courses', $args );

Setting has_archive to true causes WordPress to generate a rewrite rule for the archive using the rewrite slug, which is not what you want in your case. Instead, explicitly specify the archive slug as a string and the correct rules will be generated:

$args = array(
    'has_archive'   => 'courses',
    'rewrite'       => array('slug' => 'courses/%course-type%','with_front' => false),
    // the rest of your args...
);
register_post_type( 'courses', $args );
Source Link
Milo
  • 78.8k
  • 4
  • 127
  • 168

Setting has_archive to true causes WordPress to generate a rewrite rule for the archive using the rewrite slug, which is not what you want in your case. Instead, explicitly specify the archive slug as a string and the correct rules will be generated:

$args = array(
    'has_archive'   => 'courses',
    'rewrite'       => array('slug' => 'courses/%course-type%','with_front' => false),
    // the rest o fyour args...
);
register_post_type( 'courses', $args );