• I’m looking to retrieve the custom taxonomy slug (or permalink) to use as a way to list all the terms in my custom taxonomy with links to their archive pages. Here is the code i have:

    $taxonomyname = get_query_var('taxonomy');
    		echo '<h3>All ' . $taxonomyname .'</h3><br/>';
    		$terms = get_terms($taxonomyname);
    		echo "<ul>";
    		foreach ($terms as $term) {
    			echo "<li><a href='". site_url('/favorite-foods/','')  .$term->slug. "'>" .$term->name. "</a></li>";
    		}
    		echo "</ul>";

    the part that says
    <a href='". site_url('/favorite-foods/','') .$term->slug. "'>" .$term->name. "</a>
    i would like to replace with something like this:
    <a href='". site_url() . $my-custom-taxonomy-rewrite-slug . $term->slug . "'>" .$term->name. "</a>

    If anyone can point me in the right direction, i would be much obliged!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You’ve probably fixed it by now, but in case anyone else comes across this problem, you need to declare $wp_post_types as global and then use $wp_post_types[$post_type]->rewrite['slug'].

    I think a plugin, Taxonomic SEO Permalink can solve your problem. I created this plugin because I wanted to use custom taxonomies in permalink just like we do with %category% or %tag%.

    Recently I added support for sub-taxonomy which might not be a perfect solution but it solved problem of sub-taxonomy by a fix.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Retrieve Custom Taxonomy Rewrite Slug’ is closed to new replies.