Archived topic
Change dynamic link url prefix
5 replies · Started by Sajjad Mahmud on July 20, 2022
I have added custom taxonomies using CPT UI.
taxonomy name: "Subject"
URL prefix: "subject/"
I have created a button and added dynamic link option using this custom term.
Button links work perfectly.
url is taking to me: mysite.com/subject/math
but for some reason I want this url to be: mysite.com/subject-math
I want to change "/" with "-".
How can i do that?
Hello there,
The permalink structure is controlled by WordPress.
One approach might be to change the slug name of “Math” to subject-math.
And then remove the category in the URL.
This article might be helpful: https://muffingroup.com/blog/remove-category-from-wordpress-url/
It might be good to ask here: https://wordpress.org/support/forum/wp-advanced/
Hope this clarifies!
I Have changed my rankmath breadcrumb url by using this filter. Their support team provided me this code and it works perfectly.
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
if(false != is_singular('post')){
$id = get_the_ID();
$url = 'https://'.$_SERVER['HTTP_HOST'] .'/';
array_splice( $crumbs, 1, 0, array(array(
$subject[0]->name,
$url.'subject/'.$subject[0]->slug
)) );
}
return $crumbs;
}, 10, 2);
How can i do same thing using a filter in generatepress dynamic links?
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
if(false != is_singular('post')){
$id = get_the_ID();
$subject = get_the_terms( $id, 'subject' );
$url = 'https://'.$_SERVER['HTTP_HOST'] .'/';
array_splice( $crumbs, 1, 0, array(array(
$subject[0]->name,
$url.'subject/'.$subject[0]->slug
)) );
}
return $crumbs;
}, 10, 2);
Sorry I missed one line. This is. the code that rankmath provided me.
Please give me a solution of how can i do this to dynamic link also? using filters
Hi there,
can we see a post with that breadcrumb so we can understand what it is your trying to achieve