1

I would like to show in a custom taxomony list icons instead of taxonomy name , but just for the ones with image asociated, where there is no image let show the taxonomy name .

i have installed taxonomy-images plugin also , but it only adds the images , does not replace the taxonomy name. tnx

this is the code i have in the archive{custom type}.php file

<?php query_posts( array( 'post_type' => 'custom_type','posts_per_page' => 20 ) ); ?>

                        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

                        <div class="col-md-3 clearfix"><div class="row"><article id="post-<?php the_ID(); ?>" <?php post_class( 'clearfix' ); ?> role="article">

                             <?php // end article header ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
                            <section class="entry-content" style="text-align:center;padding:20px;">
                            <div class="thumcap2"><?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
  the_post_thumbnail(thumbnail);
} 
?></a><a href="<?php the_permalink() ?>" class="title2" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>


                            </section> <?php // end article section ?>

                            <footer class="article-footer" style="text-align:center;">
<?php
                                    printf( __( ' %4$s', 'bonestheme' ), get_the_time( 'Y-m-j' ), get_the_time( __( 'F jS, Y', 'bonestheme' )), bones_get_the_author_posts_link(), get_the_term_list( get_the_ID(), 'custom_cat', ' ', ' | ', '' ) );
                                ?>
                            </footer> <?php // end article footer ?>

                        </article></div></div> <?php // end article ?>

                        <?php endwhile; ?><div class="clearfix"></div>
7
  • 1
    First of all, don't use query_posts. Second, it's unclear what you've tried yourself so far and what went wrong. Please elaborate. – engelen Jun 22 '14 at 10:25
  • Just to add, showposts has been depreciated a long time ago. You should be using posts_per_page – Pieter Goosen Jun 22 '14 at 10:59
  • Well , i suppose that better is if you have a look at the live website , www.hh-escorts.de – Maurizio Jun 22 '14 at 11:03
  • Well , access the live website ,hh-escorts.de ,if you click on the menu tab All Models , you will call a template all-models.php where the above code is contained ,under each model thumbnail , as u can see are shown the model categories (wich are in fact custom post type taxonomies "custom_cat") the point is that if i have as taxonimies , the city , and some other like Blonde, travel, bisex etc , the visualization will be to big , and it will deform the grid view , so for all other that are not the cities i want to add an icon instead of the taxonomy name – Maurizio Jun 22 '14 at 11:12
  • p.s. : and if i dont use the query , the template will not understand wich post_type archive it has to show – Maurizio Jun 22 '14 at 11:13
0

i managed to fix it
without plugin , just saved in the theme image path pict with taxonomz slug name .png and this code modification

<footer class="article-footer" style="text-align:center;">
 <?php  //$terms= apply_filters( 'taxonomy-images-list-the-terms', '', array('taxonomy'     => 'custom_cat',)); ?>
<?php //print_r( $terms); ?>
<?php  $terms = get_the_terms( $post->ID, 'custom_cat' ); 
$numcat=sizeof($terms);
 foreach ( $terms as $term ) {


 $term_link = get_term_link( $term, 'custom_cat' );
 if( file_exists( TEMPLATEPATH .'/images/'. $term->slug .'.png') ){
?>
    <a rel="tag" href="<?php echo $term_link; ?>"><img title="<?php  echo $term->name; ?>" style="height: 21px; width: 21px;" src="<?php echo  get_template_directory_uri() . '/images/' . $term->slug . '.png' ?>" alt="<?php  echo $term->name; ?>"></a>| 
<?php }else{ ?>
 <a rel="tag" href="<?php echo $term_link; ?>"><?php  echo $term->name; ?></a>| 
 <?php } }

                                    //printf( __( ' %4$s', 'bonestheme' ), get_the_time( 'Y-m-j' ), get_the_time( __( 'F jS, Y', 'bonestheme' )), bones_get_the_author_posts_link(), get_the_term_list( get_the_ID(), 'custom_cat', ' ', ' | ', '' ) );
                                ?>
                            </footer> <?php // end article footer ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.