ThemeShaper Forums » Thematic

[closed]

hide particular tags in postfooter

(9 posts)
  • Started 8 years ago by umberto
  • Latest reply from umberto
  • This topic is resolved
  1. umberto
    Member

    I'm using a particular tag to conditionally style a set of posts. However, the tag itself is pretty much irrelevant and a distraction in the post footer tag list. So I'm looking for a way to hide it.

    Being at the very lower end of the php learning curve I'm pretty stumped. There is a 'hidden tags' plug-in which doesn't seem to work.

    The get_the_tag_list function doesn't appear to have exclude capabilities. Other solutions don't sit nicely with the thematic post footer.

    So I'm just putting it out there in case anyone has had a play with this sort of thing and has a neat snippet that might do the job or some ideas to work with.

    Posted 8 years ago #
  2. instead of get_the_tag_list you could try get_the_tags and make your own list from that:

    http://codex.wordpress.org/Function_Reference/get_the_tags

    you'll see there is a section called "Display code bases on different tag values". you might be able to adapt that so that your conditional is

    $this_tag->name != "yourhiddentag"

    ymmv. good luck.

    Posted 8 years ago #
  3. Hey everyone. Just discovered Thematic a few days ago and am still fumbling around. Maybe there is a better solution for umberto's question ...

    Anyway, try this umberto, it works for me:

    function exclude_post_format_tag( $args )
    {
    	global $post;
    	$tags = wp_get_post_tags($post->ID);
    	$limit = count( $tags );
    	$i = 0;
    	$html = ' and tagged ';
    	foreach ($tags as $tag)
    	{
    		// exclude Format Tag ID of 16
    		if ( $tag->term_id != 16 )
    		{
    			$html .= "<a>term_id)."\">" . ucwords($tag->name) . "</a> ($tag->count related pages)";
    			if ( ++$i < $limit )
    				$html .= ", ";
    			else
    				$html .= ". ";
    		}
    	}
    	return $html;
    }
    add_filter( 'thematic_postfooter_posttags' , 'exclude_post_format_tag' );

    -Jeff

    Posted 8 years ago #
  4. Don't know if it's the forums or my pasting ability :), but this is the correct line to replace what's above:

    $html .= "<a href=\"". get_tag_link($tag->term_id)."\">" . ucwords($tag->name) . "</a> ($tag->count related pages)";

    -Jeff

    Posted 8 years ago #
  5. i think it is your pasting ability. be sure to put your code between two backtick marks... on an american keyboard they are in the top left sharing a key with the ~

    Posted 8 years ago #
  6. umberto
    Member

    Thanks -

    @Jeff - I'm getting an error:
    "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING"
    relating to this line:
    $html .= "<a>term_id)."\">" . ucwords($tag->name) . "</a> ($tag->count related pages)";
    Don't really know what that means but I'm about to do some research...

    @helga - yeah I'll have a look at that again. I was hoping to work with the current postfooter structure as closely as poss to keep upgrades etc smooth, but worth a try. I'm starting to think about other avenues like custom post types which may suit the larger picture anyway.

    I'll report back when I get some progress.

    Posted 8 years ago #
  7. your concatenation is a little borked. that error just means your ' aren't properly opening and closing.

    untested, but try:

    $html .= '<a href="'. get_tag_link($tag->term_id).'">' . ucwords($tag->name) . '</a>'. ($tag->count related pages);

    i was going to mention that a custom taxonomy might be appropriate. maybe this will be helpful:
    http://justintadlock.com/archives/2011/01/14/rethinking-how-news-themes-work

    Posted 8 years ago #
  8. umberto
    Member

    Ok, somehow I missed the two posts after Jeff's first reply! ...but that new line fixes that error and hides the tag - thanks - I'll have a play with that.

    Helga - nice - thanks. Have just been re-reading his piece on custom post types. There's a mention there of Post Formats which is another possibility with the handy conditional tag - has_post_format

    cheers

    Posted 8 years ago #
  9. umberto
    Member

    ...given that Post Formats are essentially custom taxonomies it would be nice if there was an equivalent tag. However the closest thing I can find is "is_tax()" which depends on the taxonomy archive page actually being displayed.

    I'd be interested to hear thoughts on fashioning a conditional statement that would enable formatting a post based on one of its taxonomies.

    cheers

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.