• DonTimo

    (@dontimo)


    Hello,
    I’ve created custom post type ‘projects’ with the taxonomy ‘projecttype’ and I’m trying to get only the taxonomy into the permalink like this:

    https://www.url.com/%projecttype%/ -> as overview page for every taxonomy
    https://www.url.com/%projecttype%/%postname%/ -> the single post

    Everything I tried results in things like:
    https://www.url.com/projecttype/%projecttype%/ and https://www.url.com/projects/%postname/
    where the slugs I’ve chosen in functions.php while registering the post type and the taxonomy is prepended

    So how can I get now this permalink structure mentioned at first?

    Another problem I encountered was that the post_type_link filter used with substituting a %placeholder% somehow affects all pages which results then in 404 errors for all other standard pages while this CPT thing still does not work.

    Hope someone knows a solution to this one.

    Regards,
    DonTimo

    • This topic was modified 8 years ago by DonTimo.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello there,

    Use rewrite option “with_front” for removing the base slug from the permalink(URL). Add the below code in your functions.php file where you have created your custom post type.

    'rewrite' => array(
    	'slug'	=> 'your_slug',
            'with_front'  => false,
    	  )

    After adding this code to functions.php file, make sure to go to Settings > Permalinks and re-save your settings, otherwise you will probably end up with a 404 page.

    If you created custom post type in a theme I will suggest you use child theme rather then editing theme template files since it will be easier for you to find that in the future and unless you’re using child theme it would be overridden with the next theme update.

    Let me know it will help or not.

    Thread Starter DonTimo

    (@dontimo)

    Hello Poonam,

    thanks for your reply. But this ‘with_front’-setting will only prepend or remove the part one sets in the permalink settings e.g. ‘blog/’. Problem for me here is that I want to get rid also of the cpt slug ‘projects’ and replace it by the projecttype as mentioned above. And for the taxonomy-pages (the projecttypes) it should only be the taxonomy name itself as permalink.

    I already tried some cpt permalink plugins but they could not help either. Maybe there is a different approach I could try?

    Regards,
    DonTimo

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Use only taxonomies in custom post type permalinks’ is closed to new replies.