Esempio n. 1
0
    function widget($args, $instance)
    {
        extract($args);
        /* User-selected settings. */
        $title = apply_filters('widget_title', $instance['title']);
        $category = $instance['category'];
        $number_of_posts = $instance['number_of_posts'];
        $show_image = isset($instance['show_image']) ? $instance['show_image'] : false;
        $posts_query = array('numberposts' => $number_of_posts);
        if ($category != -1) {
            $posts_query['category'] = $category;
        }
        $posts = get_posts($posts_query);
        /* Before widget (defined by themes). */
        echo $before_widget;
        /* Title of widget (before and after defined by themes). */
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        echo '<div class="recent-posts">';
        foreach ($posts as $post) {
            $img = null;
            if ($show_image) {
                $post_image = get_post_thumbnail($post->ID);
            }
            ?>

			<div class="post">
				<div class="cl">&nbsp;</div>
				<?php 
            if ($show_image && isset($post_image)) {
                ?>

					<img src="<?php 
                echo $post_image;
                ?>
" alt="<?php 
                echo apply_filters('the_title', $post->post_title);
                ?>
" />
					<div class="cnt">
				<?php 
            } else {
                ?>

					<div class="cnt" style="width: 100%">
				<?php 
            }
            ?>

					<h3><a href="<?php 
            echo get_permalink($post->ID);
            ?>
"><?php 
            echo apply_filters('the_title', $post->post_title);
            ?>
</a></h3>
					<p><?php 
            echo shortalize(apply_filters('the_content', $post->post_content), 15);
            ?>
</p>
				</div>
				<div class="cl">&nbsp;</div>
			</div>
			<?php 
        }
        echo '</div><!-- Recent Posts -->';
        /* After widget (defined by themes). */
        echo $after_widget;
    }
Esempio n. 2
0
function lion_post_list($type = 'latest', $num = 5)
{
    if ($type == 'popular') {
        $the_query = new WP_Query(array('posts_per_page' => $num, 'orderby' => 'meta_value_num', 'meta_key' => '_post_like'));
    } elseif ($type == 'modified') {
        $the_query = new WP_Query(array('posts_per_page' => $num, 'orderby' => 'modified'));
    } else {
        $the_query = new WP_Query(array('posts_per_page' => $num, 'orderby' => 'latest'));
    }
    $post_list = '';
    while ($the_query->have_posts()) {
        $the_query->the_post();
        $post_list .= '<li class="list-item u-clearfix"><a href="' . get_permalink() . '" title="' . get_the_title() . '"><div class="list-item-image';
        if (!lion_is_has_image()) {
            $post_list .= ' no-image';
        }
        $post_list .= ' u-floatLeft" style="background-image:url(' . get_post_thumbnail() . ')"></div><div class="list-item-title">' . get_the_title() . '</div><div class="list-item-meta">' . get_the_date('Y-m-d');
        if (function_exists('wpl_get_like_count')) {
            $post_list .= '<span class="middotDivider"></span>' . wpl_get_like_count() . ' likes';
        }
        $post_list .= '</div></a></li>';
    }
    wp_reset_postdata();
    return $post_list;
}
Esempio n. 3
0
		<a href="<?php 
        the_permalink();
        ?>
"><h1><?php 
        the_title();
        ?>
</h1></a>				
			——·&nbsp;&nbsp;&nbsp;<?php 
        the_time('Y年n月j日');
        ?>
 | <?php 
        comments_popup_link('0 条评论', '1 条评论', '% 条评论', '', '评论已关闭');
        ?>
&nbsp;&nbsp;&nbsp;·——
			<br><br><?php 
        get_post_thumbnail();
        ?>
			</center>
			<hr>
			<psize><?php 
        the_content();
        ?>
</psize>
			<hr>
			<p class="clearfix">《 <?php 
        next_post_link('%link ');
        ?>
</a>
			<span class="floatright"><?php 
        previous_post_link('%link ');
        ?>
                        echo $tag["tag_name"];
                        ?>
</a>,<?php 
                    }
                }
            }
            ?>
                                    |
                                    <i class="icon-calendar"></i> <?php 
            echo gettimeurl($post['post_date'], $post['post_type']);
            ?>
                                </p>

                            </div>
                            <!--<p> <?php 
            echo get_post_thumbnail($post);
            ?>
</p>-->

                            <p><?php 
            echo mb_substr(strip_tags($post["post_content"]), 0, 400, "UTF-8");
            ?>
</p>
                            <a class="btn btn-link" href="<?php 
            echo get_post_url($post);
            ?>
">阅读详细
                                <i
                                        class="icon-angle-right"></i></a>
                        </div><?php 
        }