Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I wanted to rename the slug to use a custom rewrite with a prefix or suffix that I choose. For example, if the tag name is "product" I want to use a rewrite with a slug that says "product-powerpint-ppt" so the final URL will look like /tag/product-powerpoint-ppt instead of /tag/product

I was looking for a solution to this problem from time ago, without relying on htaccess rules, just tweaking WordPress or using a plugin. Anyone had the same question or can advice on a possible solution?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Filter 'term_link'. Sample code, not tested:

add_filter( 'term_link', 'wpse_72848_change_tag_slug', 10, 3 );

function wpse_72848_change_tag_slug( $termlink, $term, $taxonomy )
{
    if ( 'post_tag' !== $taxonomy )
        return $termlink;

    if ( 'product' === $term->slug )
        return str_replace( '/product/', '/product-powerpoint-ppt/', $termlink );

    return $termlink;
}
share|improve this answer
    
Hi @toscho, this worked straightforward. Thanks. I was able to rewrite the tags and other taxonomies using this snippet. However, when I try to access the url generated, I get a 404 error page. Do you know or have a clue how can I access the correct tag page when I use the link with the suffix? It may exist other similar filter to use. –  julianm Nov 16 '12 at 15:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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