</div>
                       
                        
                    </div>
                    
                    <?php 
        } elseif ($photo = hathor_get_images('numberposts=1', true)) {
            ?>
    
                    <div class=" imgwrap">
                    <a href="<?php 
            the_permalink();
            ?>
"><?php 
            echo wp_get_attachment_image($photo[0]->ID, 'medium');
            ?>
</a>
                    <div class="ch-item ch-img-1 "> 
                   
                  
						
                        
Exemple #2
0
 function widget($args, $instance)
 {
     extract($args);
     /* Our variables from the widget settings. */
     $title = apply_filters('widget_title', $instance['title']);
     $num = $instance['num'];
     $cat = $instance['cat'];
     /* Before widget (defined by themes). */
     echo $before_widget;
     /* Display the widget title if one was input (before and after defined by themes). */
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     /* Display a containing div */
     echo '<div class="thn_feat">';
     /* Display Posts */
     if ($num) {
         $popular = new WP_Query('ignore_sticky_posts=1&cat=' . $cat . ' &posts_per_page=' . $num);
     }
     echo '<ul>';
     while ($popular->have_posts()) {
         $popular->the_post();
         echo '<li>';
         echo '<a class="thn_wgt_thumb" href="' . get_permalink(get_the_ID()) . '" title="' . get_the_title() . '">';
         if (has_post_thumbnail()) {
             echo '' . the_post_thumbnail('thumbnail') . '';
         } elseif ($photo = hathor_get_images('numberposts=1', true)) {
             echo '' . wp_get_attachment_image($photo[0]->ID, $size = 'thumbnail') . '';
         } else {
             echo '<img src="' . get_template_directory_uri() . '/images/blank_img2.png" alt="' . get_the_title() . '" class="thumbnail"/>';
         }
         echo '</a>';
         echo '<div class="widget_content">';
         echo '<a class="thn_wgt_tt" href="' . get_permalink(get_the_ID()) . '" title="' . get_the_title() . '">' . get_the_title() . '</a><br />';
         echo '' . hathor_excerpt('hathor_excerptlength_index', 'hathor_excerptmore') . '';
         echo '</div>';
         echo '</li>';
     }
     echo '</ul>';
     echo '</div>';
     /* After widget (defined by themes). */
     echo $after_widget;
 }