示例#1
0
                <div class="post_image">
                     <!--CALL TO POST IMAGE-->
                    <?php 
        if (has_post_thumbnail()) {
            ?>
                    <div class="imgwrap">
                    <a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_post_thumbnail('medium');
            ?>
</a></div>
                    
                    <?php 
        } elseif ($photo = asteria_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>
                
                    <?php 
        } else {
            ?>
                    
示例#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'];
     $type = $instance['type'];
     /* 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 class="ast_wdgt_' . $type . '">';
     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 ('layout1' == $type) {
             if (has_post_thumbnail()) {
                 echo '' . the_post_thumbnail('thumbnail') . '';
             } elseif ($photo = asteria_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_img.png" alt="' . get_the_title() . '" class="thumbnail"/>';
             }
         } else {
             if (has_post_thumbnail()) {
                 echo '' . the_post_thumbnail('medium') . '';
             } elseif ($photo = asteria_get_images('numberposts=1', true)) {
                 echo '' . wp_get_attachment_image($photo[0]->ID, $size = 'medium') . '';
             } else {
                 echo '<img src="' . get_template_directory_uri() . '/images/blank_img.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 />';
         if ($type == 'layout1' || $type == 'layout2') {
             echo '' . asteria_excerpt('asteria_excerptlength_index', 'asteria_excerptmore') . '';
         } else {
             echo '';
         }
         echo '</div>';
         echo '</li>';
     }
     echo '</ul>';
     echo '</div>';
     /* After widget (defined by themes). */
     echo $after_widget;
 }