示例#1
0
文件: index.php 项目: studevguy/wp-sp
        <div class="row">
            <div id="content" class="post_list category_study col-md-9 col-xs-12 site-content">

                <?php 
// The Loop
while (have_posts()) {
    the_post();
    //render the content
    echo "<div class='article_summary row'>";
    echo "<div class='article_thumbnail col-sm-3 col-xs-4'><a href='";
    the_permalink();
    echo "'>";
    if (has_post_thumbnail()) {
        the_post_thumbnail('thumbnail');
    } else {
        default_thumbnail('small');
    }
    echo "</a></div>";
    echo "<div class='article_content col-sm-9 col-xs-8'>";
    echo "<a href='";
    the_permalink();
    echo "'><title class='title'>";
    the_title();
    echo "</title></a>";
    echo "<div class='excerpt'>";
    the_excerpt();
    echo "</div>";
    echo "</div>";
    echo '<p class="posted_date col-md-offset-3 col-md-9 col-xs-12"><span>';
    the_date('G:i - j M Y');
    echo '</span></p>';
示例#2
0
                                <?php 
    if (has_post_thumbnail()) {
        the_post_thumbnail();
    } else {
        default_thumbnail();
    }
    ?>
                            </a>

                            <div class='gaussian_blur'>
                                <div class='wrapper'>
                                    <?php 
    if (has_post_thumbnail()) {
        the_post_thumbnail();
    } else {
        default_thumbnail();
    }
    ?>
                                </div>
                            </div>
                        </div>
                        <div class='article_info'>
                            <div class='title'>
                                <h2><a href='<?php 
    the_permalink();
    ?>
'><?php 
    the_title();
    ?>
 </a></h2>
                            </div>
示例#3
0
    function widget($args, $instance)
    {
        // Only show widget if on a post page.
        if (!is_single()) {
            return;
        }
        global $post;
        $post_old = $post;
        // Save the post object.
        extract($args);
        if (!$instance["title"]) {
            $instance["title"] = "Related Posts";
        }
        // Excerpt length filter
        $new_excerpt_length = create_function('$length', "return " . $instance["excerpt_length"] . ";");
        if ($instance["excerpt_length"] > 0) {
            add_filter('excerpt_length', $new_excerpt_length);
        }
        $tags = wp_get_post_tags($post->ID);
        if ($tags) {
            $tag_ids = array();
            foreach ($tags as $individual_tag) {
                $tag_ids[] = $individual_tag->term_id;
            }
            $args = array('tag__in' => $tag_ids, 'post__not_in' => array($post->ID), 'showposts' => $instance['num'], 'ignore_sticky_posts' => 1);
            $my_query = new WP_Query($args);
            if ($my_query->have_posts()) {
                echo $before_widget;
                // Widget title
                echo $before_title . $instance["title"] . $after_title;
                // Post list
                echo "<ul class='row'>\n";
                while ($my_query->have_posts()) {
                    $my_query->the_post();
                    ?>
                    <li class="related-post-item col-md-12 col-sm-6">
                        <a class="post-title" href="<?php 
                    the_permalink();
                    ?>
" rel="bookmark"
                           title="Permanent Link to <?php 
                    the_title_attribute();
                    ?>
"><?php 
                    the_title();
                    ?>
</a>

                        <?php 
                    if (isset($instance['date'])) {
                        ?>
                            <p class="post-date"><?php 
                        the_time("j M Y");
                        ?>
</p>
                        <?php 
                    }
                    ?>

                        <?php 
                    if (function_exists('the_post_thumbnail') && current_theme_supports("post-thumbnails") && isset($instance["thumb"])) {
                        ?>
                            <a href="<?php 
                        the_permalink();
                        ?>
" title="<?php 
                        the_title_attribute();
                        ?>
">
                                <?php 
                        if (has_post_thumbnail()) {
                            the_post_thumbnail('thumbnail');
                        } else {
                            default_thumbnail('small');
                        }
                        ?>
                            </a>
                        <?php 
                    }
                    ?>

                        <?php 
                    if (isset($instance['excerpt'])) {
                        ?>
                            <?php 
                        the_excerpt();
                        ?>
                        <?php 
                    }
                    ?>

                        <?php 
                    if (isset($instance['comment_num'])) {
                        ?>
                            <p class="comment-num">(<?php 
                        comments_number();
                        ?>
)</p>
                        <?php 
                    }
                    ?>
                    </li>
                    <?php 
                }
                echo "</ul>\n";
                echo $after_widget;
            }
        }
        remove_filter('excerpt_length', $new_excerpt_length);
        $post = $post_old;
        // Restore the post object.
    }