Forums

[resolved] 'If statement' to determine how many tags a post has (3 posts)

  1. cboakes
    Member
    Posted 3 weeks ago #

    Hi there,

    This question is related to a question I posted up yesterday (that was resolved). I'm really stuck on this and if anyone could help me out it would be immensely appreciated:

    Basically the following script displays:

    First half - posts that have more than one tag associated with them
    Second half - all posts single tags.

    My query is, how do I then exclude the the tags already displayed in the first half from the second half. Therefore displaying only posts that have one tag associated with them.

    <?php
    	$tags = get_tags( array('orderby' => 'name', 'order' => 'ASC') );
    	foreach ( (array) $tags as $tag ) {
    
    	$post_tag = get_term($tag, 'post_tag' );
    	$args=array('orderby' => 'date', 'showposts' => -1, 'tag__in' => array($tag->term_id), 'caller_get_posts'=>1);
    	$posts=get_posts($args);
    
    	if ($post_tag->count > 1) {
    
    		//Display posts with more than one tag	
    
    	} else if ($post_tag->count == 1) {
    
    		//Here I am trying to display posts with only one tag
    
    	}
    	}
    ?>

    Thanks!

  2. cboakes
    Member
    Posted 3 weeks ago #

    Does anyone know how I might even start to do this - I'm really stuck?

    Thanks

  3. cboakes
    Member
    Posted 2 weeks ago #

    For anyone who is interested:

    http://wordpress.org/support/topic/328118

Reply

You must log in to post.

About this Topic

Tags