WordPress.org

Ready to get started?Download WordPress

Forums

Taxonomy Terms List
Remove Link (4 posts)

  1. Niraj Chauhan
    Member
    Posted 3 years ago #

    Hey hi,
    I just want to ask you, the taxonomies which are been displayed, after the post, I would like to remove the link(<a href) tag from it,
    So that it will be just terms without links,

    How can I do this?

    http://wordpress.org/extend/plugins/taxonomy-terms-list/

  2. valentin88
    Member
    Posted 3 years ago #

    Hi,

    If you are using <?php get_the_term_list( $id, $taxonomy, $before, $sep, $after ) ?> , go to wp-includes/category-template.php, locate the function and remove the unnecessary code. Your function will have to look like this :

    function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after = '' ) {
    	        $terms = get_the_terms( $id, $taxonomy );
    
    	        if ( is_wp_error( $terms ) )
    	                return $terms;
    
    	        if ( empty( $terms ) )
    	                return false;
    
    	        foreach ( $terms as $term ) {
    	                $link = get_term_link( $term, $taxonomy );
    	                if ( is_wp_error( $link ) )
    	                        return $link;
    	                $term_links[] = $term->name ;
    	        }
    
    	        $term_links = apply_filters( "term_links-$taxonomy", $term_links );
    
    	        return $before . join( $sep, $term_links ) . $after;
    	}

    I hope it helps.
    Cheers!

  3. Eric
    Member
    Posted 3 years ago #

    Hi Everyone,

    Just for those who struggle with php inside of WordPress I'd like to clarify something.

    The only difference in the code provide by valentin88 and what is originally found inside of wp-includes/category-template.php is this

    $term_links[] = $term->name ;
    
    /* instead of the following */
    
    $term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';

    And in addition to the Taxonomy Terms List Plugin...

    I'm also trying another plugin by the same author - Michael Fields - called Taxonomy List Shortcode

    At first I was wondering if changing wp-includes/category-template.php to remove links from the Taxonomy Terms List plugin would effect the other plugin.

    And it seems there is no issues. I hope this is useful.

    One question though....

    When new versions of WordPress are released will upgrading cause the edits to wp-includes/category-template.php to be overwritten?

    Thanks and I look forward to your replies

    Eric

  4. valentin88
    Member
    Posted 3 years ago #

    Hi Eric,

    Unfortunately yes, when you will upgrade the wp version, the category-template will be overwritten .

    I faced with this problem too, and I resolved it by copying the function in the functions.php from my theme folder , and I've named it get_the_term_list_unlinked. Of course, if you are using multiple themes, you will have to copy the function to every functions.php of these themes.

    I hope this is the answer you are looking for .
    Good luck!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic