-
AuthorPosts
-
April 15, 2016 at 10:36 pm #615183
Hi,
I’m using a code-snippet plugin, to add snippets to ENFOLD’s function.php.
There I added a found snippet://Register tag cloud filter callback add_filter('widget_tag_cloud_args', 'tag_widget_limit'); //Limit number of tags inside widget, exclude ID34, sort by count function tag_widget_limit($args){ //Check if taxonomy option inside widget is set to tags if(isset($args['taxonomy']) && $args['taxonomy'] == 'post_tag'){ $args['number'] = 12; //Limit number of tags $args['exclude'] = 34; $args['orderby'] = 'count'; $args['order'] = 'DESC'; } return $args; }
It works fine for the tag cloud widget.
I’m not so good in PHP, so could you please help me how to extend this snippet, so that a tag ID34 is excluded below a single post?
Or doesn’t this work via a code-snippet plugin and do I need to edit a theme file for this?Thank you.
April 18, 2016 at 4:59 am #615998Hi Chris,
It looks like it should exclude just that post, could you please provide us with a temporary admin login so that we can take a closer look? You can post the details in the Private Content section of your reply.
Best regards,
RikardApril 18, 2016 at 12:54 pm #616386Hi Rikard,
thank you, but I found last night a snippet in the WP forum, which works perfectly:
function mtstheme_filter_tags( $term_links ) { $result = array(); $exclude_tags = array( 'getestet' ); foreach ( $term_links as $link ) { foreach ( $exclude_tags as $tag ) { if ( stripos( $link, $tag ) !== false ) continue 2; } $result[] = $link; } return $result; } add_filter( "term_links-post_tag", 'mtstheme_filter_tags', 100, 1 );
in case someone needs this, too.
“getestet” is my tag, that should not appear below the single post view (no matter what post).I put this snippet in my Code-Snippet-Plugin instead of working with the theme’s original functions.php :-)
April 19, 2016 at 11:13 am #617289 -
AuthorPosts
- You must be logged in to reply to this topic.