Exemplo n.º 1
0
/**
 * wwh_home_page_article 首页文章
 * 
 * @param mixed $cat_id 分类ID
 * @param string $location 位置
 * @param string $art_name 一级标题 
 * @param string $em 二级标题
 * @access public
 * @return void
 */
function wwh_home_page_article($cat_id, $location = 'top', $art_name = '文章', $em = '文章')
{
    $args = array('cat' => $cat_id, 'posts_per_page' => 3, 'ignore_sticky_posts' => 1);
    $str = '<article class="article article-' . $location . ' container container-margin">';
    $str .= '<h2>' . $art_name . '</h2><span>' . $em . '</span>';
    $str .= '<div class="row">';
    query_posts($args);
    while (have_posts()) {
        the_post();
        $str .= '<div class="col-md-4">';
        $str .= '<a href="' . get_the_permalink() . '">';
        $str .= '<img src="' . post_thumbnail_src() . '" alt="' . wwh_the_title() . '" width="293px" height="195px" />';
        $str .= '</a>';
        $str .= '<a href="' . get_the_permalink() . '"><h4>' . wwh_the_title() . '</h4></a>';
        $str .= '<p class="publish-time">';
        $str .= '<span class="glyphicon glyphicon-time" aria-hidden="true"></span>';
        $str .= '' . get_the_time('Y-m-d') . '';
        $str .= '</p>';
        $str .= '<div class="post-content" id="clampjs">';
        $str .= strip_tags(get_the_content());
        $str .= '</div>';
        $str .= '<a class="btn view-more" href="' . get_the_permalink() . '">查看更多</a>';
        $str .= '</div>';
    }
    $str .= '</div>';
    $str .= '</article>';
    return $str;
}
Exemplo n.º 2
0
<!-- 文章内容 -->
    <?php 
while (have_posts()) {
    the_post();
    ?>
            <div>
                <img src="<?php 
    echo post_thumbnail_src();
    ?>
" alt="<?php 
    wwh_the_title();
    ?>
"  height="296px" width="89%" />
            </div>
            <h1><?php 
    echo wwh_the_title();
    ?>
</h1>
            <div class="entry-footer">
                <span class="glyphicon glyphicon-time" aria-hidden="true"></span>
                <?php 
    the_date('Y-m-d');
    ?>
                <span class="glyphicon glyphicon-user" aria-hidden="true"></span>
                <?php 
    the_author();
    if (get_the_category()) {
        $i = 0;
        $categoryName = '';
        foreach (get_the_category() as $category) {
            if ($i == 5) {