示例#1
0
    public function widget($args, $instance)
    {
        ob_start();
        extract($args);
        $title = '';
        $cache = '';
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $number = !empty($instance['number']) ? absint($instance['number']) : 2;
        echo $args['before_widget'];
        ?>
        
         <?php 
        if ($number != 0) {
            if (!empty($title)) {
                echo $args['before_title'];
                echo esc_attr($instance['title']);
                ?>
 <?php 
                echo $args['after_title'];
            }
            $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true)));
            if ($r->have_posts()) {
                ?>
<ul>
            <?php 
                while ($r->have_posts()) {
                    $r->the_post();
                    ?>
                <li>
                    <?php 
                    $thumbnail = get_post_thumbnail_id();
                    $img_url = wp_get_attachment_image_src($thumbnail, 'full');
                    //get img URL
                    $n_img = aq_resize($img_url[0], $width = 81, $height = 81, $crop = true, $single = true, $upscale = true);
                    ?>
                    <?php 
                    if (!empty($n_img)) {
                        ?>
<img src="<?php 
                        echo esc_url($n_img);
                        ?>
" alt="" class="alignleft"><?php 
                    }
                    ?>
                    <h3> <a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    creativ_post_title();
                    ?>
</a></h3>
                    <span class="metabox">
                        <?php 
                    if (get_the_category()) {
                        ?>
                        
                            <?php 
                        the_category('/');
                    }
                    ?>
 <span><?php 
                    echo get_the_date('F d , Y');
                    ?>
</span>
                    </span>                    
               </li>
              <?php 
                }
                ?>
            </ul>
          <?php 
            }
            ?>
     
        <?php 
            wp_reset_postdata();
            ?>
        <?php 
            $content = ob_get_clean();
            wp_cache_set('latest_post', $cache, 'widget');
            echo $content;
            echo $args['after_widget'];
            ?>
               
    <?php 
        }
        ?>
    
    <?php 
    }
示例#2
0
        _e('|', 'creativ');
        ?>
 <?php 
        echo get_the_date('d - M - Y');
        ?>
</span>
            </div><!-- end meta -->


            <div class="blog-title">
                <h3><a href="<?php 
        the_permalink();
        ?>
">
                   <?php 
        creativ_post_title();
        ?>
                </a></h3>
            </div><!-- end title -->
             <div class="blog-desc">
                  <?php 
        the_excerpt();
        ?>
            </div><!-- end desc -->

            <div class="blog-button">
                <a href="<?php 
        the_permalink();
        ?>
" title="" class="btn btn-primary border-radius"><?php 
        _e('Read more', 'creativ');