• Hi – I’d like to display a javascript lightbox or button in the sidebar when a user views a post that is tagged with a specific taxonomy.

    So far I’ve got the followingf but its not working:

    <?php if(has_term( 'hong-kong-2013', 'events', $post->ID ) ) : ?>
    
    <?php echo 'hong kong 2013';  ?>
    
    <?php elseif(has_term( 'london-2012', 'events', $post->ID ) ) : ?>
    
    <?php echo 'london 2012'; ?>
    
    <?php endif; ?>

    Can anyone help?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Stefan

    (@stefan83)

    Sorry – it does work the taxonomy was wrong!

    Thread Starter Stefan

    (@stefan83)

    Further to my previous question, how do I then only show this content if a user (subscriber) is logged in? Thanks!

    <?php if ( $user_ID ) : // Check if logged in ?>
         Show content based on taxonomy 
    
    <?php else : // User is not logged in ?>
          Do not show content based on taxonomy 
    
    <?php endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show content based on taxonomy’ is closed to new replies.