0

So for example, I have multiple custom post types movies, games, and music, I'd like to add a custom parent slug, so the output would be like this; or the custom post type slug should be the prefix slug of it,

  • sampledomain.com/movies/the-avengers // (single-movies.php)
  • sampledomain.com/games/uncharted-4 // (single-games.php)
  • sampledomain.com/music/party-in-the-usa // (single-music.php)

and lastly the default post url/permalink would be

  • sampledomain.com/articles/sample-article-post // (single-post.php)

Is there a plugin that can help us do this? or better yet a code or sample / documentation that I can read about to make this feature happen?

5
  • This is the default behaviour for custom post types. If you want to add a prefix for regular posts you can add it by editing your permalinks format in Settings > Permalinks. Commented Jan 3, 2023 at 11:15
  • Ohhhhhh I see, the reason why it is not working for me it's because something added on my permalink, so that's the default behaviour of custom posts type, now i get it, thanks! Commented Jan 3, 2023 at 11:32
  • @JacobPeattie one last thing, If I tried to add a prefix to my regular post, it will be also applied to the custom post types, how can I prevent that from happening? Commented Jan 3, 2023 at 11:34
  • Set with_front in rewrite to false when registering the post type: developer.wordpress.org/reference/functions/register_post_type/… Commented Jan 3, 2023 at 11:59
  • Hi Read this articles about wordpress themplate hierarchy developer.wordpress.org/themes/basics/template-hierarchy Commented Jan 4, 2023 at 7:20

1 Answer 1

0

My was a mistake, I realize later that-- that is the custom post types default behavior, the reason it is not working for me because something is added to my Settings -> Permalinks that adds another prefix so the permalink of my posts is /articles/%postname%/ so the output is /movies/sample-post

I just removed the /articles/ and selected Post-name in the radio button and it works now for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.