Addig custom url rewrite rule for custom post type slug
I have a theme which defined custom post types. This post type is having a listing page and a single item page for every item. The problem is I can’t change the slug for the custom post type and for the items, I don’t know where and how… So I was thinking maybe I could rewrite these urls with WP_Rewrite.
So what I want to achieve is change:
xy.com/listing/ to xy.com/mynewname/
and all the xy.com/listing/listing-item/ to xy.com/mynewname/listing-item/
I tried to add this to my functions.php:
function listing_url_rewrite() {
add_rewrite_rule(
"mynewname",
"listing",
"top");
}
add_action( 'init', 'listing_url_rewrite' );
But nothing changed actually. So my question is, is it even possible with this rewrite_rule? If yes, what did I wrong? 🙂
Thank you very much!
Leave an answer
You must login or register to add a new answer .