• 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>
Viewing 1 replies (of 1 total)
  • 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>
Viewing 1 replies (of 1 total)
  • The topic ‘How to "else" if no description on my custom post’ is closed to new replies.