Change permalink of "Projects" i.e. /portfolio/
-
I want to use the Custom Post Type “Projects” to present the producers of the wines which my customer sells. Unfortunately, I cannot change the permalink of projects. It seems to be fixed to /portfolio/. What I need ist ../bodegas/url-to-project-element
I googled and found this: https://wordpress.stackexchange.com/questions/38576/is-it-possible-to-change-the-url-of-custom-post-types-to-hide-the-post-type-slug
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'acme_product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'products')
)
);
}
Could you provide a way to filter-hook this via child-theme functions.php?
Hello,
Thank you for the question.
Unfortunately, there is no such option in our theme and the only one way to change portfolio permalinks structure at the moment is to edit file wp-content/plugins/basel-post-types/basel-post-types.php and replace there a line. You will need to resave your permalinks structure in Dashboard -> Permalinks.
'rewrite' => array('slug' => 'portfolio'),
with this one
'rewrite' => array('slug' => 'your_slug'),
Regards
Thanks for answering.
This is not good. Not Update safety…
Could you implement this as a feature?
Here we go…you should pay me for extending your theme features 😉
//Rewrite Custom Post type "portfolio" to "my_slug"
add_filter('register_post_type_args', 'portfolio_to_my_slug', 10, 2);
function portfolio_to_my_slug($args, $post_type){
if ($post_type == 'portfolio'){
$args['rewrite']['slug'] = 'my_slug';
}
return $args;
}
Hey, thank you for posting this solution here 🙂 Much appreciated!
You are very welcome 🙂
The topic ‘Change permalink of "Projects" i.e. /portfolio/’ is closed to new replies.