WordPress.org

Ready to get started?Download WordPress

Forums

How to "else" if no description on my custom post (2 posts)

  1. Rommel
    Member
    Posted 2 years ago #

    hi,

    how to put else if no description in my custom posts category:

    here is my working code:

    <ul class="clearfix">
        	<?php
    		//list terms in a given taxonomy (useful as a widget for twentyten)
    		$taxonomy = 'supplier-post-category';
    		$tax_terms = get_terms($taxonomy);
    		?>
    
    		<?php
    		foreach ($tax_terms as $tax_term) {
    		echo
    		'<li>' .
    		'<div class="supplier-photo">'
    			.'<img src="' .$tax_term->description. '" />'.
    		'</div>' .
    
    		'<div class="supplier-name"><a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></div>
    		</li>';
    		}
    		?>
       	</ul>
  2. vtxyzzy
    Member
    Posted 2 years ago #

    Give this a try:

    <ul class="clearfix">
           <?php
          //list terms in a given taxonomy (useful as a widget for twentyten)
          $taxonomy = 'supplier-post-category';
          $tax_terms = get_terms($taxonomy);
          ?>
    
          <?php
          foreach ($tax_terms as $tax_term) {
             echo '<li>';
             if ($tax_term->description) {
                echo
                   '<div class="supplier-photo">'
                   .'<img src="' .$tax_term->description. '" />'.
                   '</div>';
             }
    
             echo '<div class="supplier-name"><a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></div>
                </li>';
          }
          ?>
    </ul>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.