예제 #1
0
                        <h4 class="entry-title">
                            <a href="<?php 
        the_permalink();
        ?>
" rel="bookmark" title="<?php 
        the_title_attribute();
        ?>
"><?php 
        the_title();
        ?>
</a>
                        </h4><!-- .entry-title -->

                        <div class="entry-meta">
                            <?php 
        creative_blog_entry_meta_custom();
        ?>
                        </div>

                    </div>

                </div><!--.related-posts-->
            <?php 
    }
    ?>

        </div><!-- .related-posts-total -->
    </div><!-- .related-posts-main -->

    <?php 
    wp_reset_postdata();
예제 #2
0
    function widget($args, $instance)
    {
        $number = !empty($instance['number']) ? $instance['number'] : 4;
        $title = isset($instance['title']) ? $instance['title'] : '';
        echo $args['before_widget'];
        ?>
        <div class="random-posts-widget" id="random-posts">
            <?php 
        global $post;
        $random_posts = new WP_Query(array('posts_per_page' => $number, 'post_type' => 'post', 'ignore_sticky_posts' => true, 'orderby' => 'rand', 'no_found_rows' => true));
        ?>

            <?php 
        if (!empty($title)) {
            echo $args['before_title'] . esc_html($title) . $args['after_title'];
        }
        ?>

            <?php 
        $i = 1;
        $post_count = $random_posts->post_count;
        while ($random_posts->have_posts()) {
            $random_posts->the_post();
            if ($i == 1) {
                echo '<div class="random-post-wrapper">';
            }
            ?>
                <div class="single-article">
                    <?php 
            if (has_post_thumbnail()) {
                ?>
                        <a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title_attribute();
                ?>
"><?php 
                the_post_thumbnail('creative-blog-featured-widget');
                ?>
</a>
                    <?php 
            }
            ?>
                    <h3 class="entry-title">
                        <a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
"><?php 
            the_title();
            ?>
</a>
                    </h3>
                    <div class="entry-meta">
                        <?php 
            creative_blog_entry_meta_custom();
            ?>
                    </div>
                </div>
                <?php 
            if ($i == $post_count) {
                echo '</div>';
            }
            $i++;
        }
        // Reset Post Data
        wp_reset_postdata();
        ?>
        </div>
        <?php 
        echo $args['after_widget'];
    }