Пример #1
0
function hui_recent_posts_most()
{
    global $wpdb;
    // $days=400;
    $days = _hui('most_list_date');
    $limit = _hui('most_list_number');
    $output = '';
    if (!_hui('most_list_style') || _hui('most_list_style') == 'comment') {
        $today = date("Y-m-d H:i:s");
        $daysago = date("Y-m-d H:i:s", strtotime($today) - $days * 24 * 60 * 60);
        $result = $wpdb->get_results("SELECT comment_count, ID, post_title, post_date FROM {$wpdb->posts} WHERE post_date BETWEEN '{$daysago}' AND '{$today}' AND post_status='publish' AND post_type='post' ORDER BY comment_count DESC LIMIT 0 , {$limit}");
        if (empty($result)) {
            $output = '<li>' . __('暂无文章!', 'haoui') . __('近期有评论的文章才会显示在这里,你也可以在主题设置中选择按阅读数排行。', 'haoui') . '</li>';
        } else {
            $i = 1;
            foreach ($result as $topten) {
                $postid = $topten->ID;
                $title = $topten->post_title;
                $commentcount = $topten->comment_count;
                if ($commentcount != 0) {
                    $output .= '<li><p class="text-muted"><span class="post-comments">' . __('评论', 'haoui') . ' (' . $commentcount . ')</span>' . hui_get_post_like($class = 'post-like', $pid = $postid) . '</p><span class="label label-' . $i . '">' . $i . '</span><a' . hui_target_blank() . ' href="' . get_permalink($postid) . '" title="' . $title . '">' . $title . '</a></li>';
                    $i++;
                }
            }
        }
    } else {
        if (_hui('most_list_style') == 'view') {
            global $post;
            $limit_date = current_time('timestamp') - $days * 86400;
            $limit_date = date("Y-m-d H:i:s", $limit_date);
            $where = '';
            $mode = 'post';
            if (!empty($mode) && $mode != 'both') {
                $where = "post_type = '{$mode}'";
            } else {
                $where = '1=1';
            }
            $most_viewed = $wpdb->get_results("SELECT DISTINCT {$wpdb->posts}.*, (meta_value+0) AS views FROM {$wpdb->posts} LEFT JOIN {$wpdb->postmeta} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID WHERE post_date < '" . current_time('mysql') . "' AND post_date > '" . $limit_date . "' AND {$where} AND post_status = 'publish' AND meta_key = 'views' AND post_password = '' ORDER  BY views DESC LIMIT {$limit}");
            if ($most_viewed) {
                $i = 1;
                foreach ($most_viewed as $post) {
                    $title = get_the_title();
                    $post_views = intval($post->views);
                    // $output .= '<li class="item-'.$i.'"><a target="_blank" href="'.get_permalink($postid).'">'._get_post_thumbnail(array()).'<h2>'.$post_title.'</h2><p>'.hui_get_post_date( get_the_time('Y-m-d H:i:s') ).'<span class="post-views">阅读('.$post_views.')</span></p></a></li>';
                    $output .= '<li><p class="text-muted"><span class="post-comments">' . __('阅读', 'haoui') . ' (' . $post_views . ')</span>' . hui_get_post_like($class = 'post-like', $pid = $postid) . '</p><span class="label label-' . $i . '">' . $i . '</span><a' . hui_target_blank() . ' href="' . get_permalink($postid) . '" title="' . $title . '">' . $title . '</a></li>';
                    $i++;
                }
            } else {
                $output = '<li>' . __('暂无文章!', 'haoui') . '</li>';
            }
        }
    }
    echo '<div class="most-comment-posts">
            <h3 class="title"><strong>' . _hui('most_list_title') . '</strong></h3>
            <ul>' . $output . '</ul>
        </div>';
}
Пример #2
0
function hui_post_excerpt()
{
    $listtype = _hui('list_type');
    while (have_posts()) {
        the_post();
        $classname = '';
        $focus = '';
        if ($listtype !== 'none') {
            $imgNum = hui_post_images_number();
            $has_thumb = has_post_thumbnail();
            if ($listtype == 'thumb') {
                $imgSingle = true;
                if ($has_thumb || $imgNum > 0) {
                    $classname = ' excerpt-one';
                }
            } else {
                if ($listtype == 'multi') {
                    $imgSingle = false;
                    if ($has_thumb || $imgNum > 0 && $imgNum < 4) {
                        $classname = ' excerpt-one';
                    } else {
                        if (!$has_thumb && $imgNum >= 4) {
                            $classname = ' excerpt-multi';
                        }
                    }
                }
            }
            $focus = hui_get_thumbnail($imgSingle, false);
            $focus = $focus ? '<p class="focus"><a' . hui_target_blank() . ' href="' . get_permalink() . '" class="thumbnail">' . $focus . '</a></p>' : '';
        }
        $pls = _hui('post_plugin');
        $author = get_the_author();
        if (_hui('author_link')) {
            $author = '<a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . $author . '</a>';
        }
        echo '<article class="excerpt' . $classname . '">';
        echo '<header>';
        if (!is_category()) {
            $category = get_the_category();
            if ($category[0]) {
                echo '<a class="cat label label-important" href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '<i class="label-arrow"></i></a> ';
            }
        }
        echo '<h2><a' . hui_target_blank() . ' href="' . get_permalink() . '" title="' . get_the_title() . _hui('connector') . get_bloginfo('name') . '">' . get_the_title() . '</a></h2>';
        if ($imgNum) {
            echo '<small class="text-muted"><span class="glyphicon glyphicon-picture"></span>' . $imgNum . '</small>';
        }
        echo '</header>', '<p class="text-muted time">' . ($pls && $pls['siteauthor'] ? get_bloginfo('name') . ' - ' : '') . $author . ' ' . __('发布于', 'haoui') . ' ' . timeago(get_gmt_from_date(get_the_time('Y-m-d G:i:s'))) . '</p>', $focus, '<p class="note">' . hui_get_excerpt_content() . '</p>', '<p class="text-muted views">' . hui_get_views() . '</span>', $pls && $pls['comm'] ? '<span class="post-comments">' . hui_get_comment_number() . '</span>' : '', hui_get_post_like($class = 'post-like'), the_tags('<span class="post-tags">' . __('标签:', 'haoui'), ' / ', '</span>'), '</p>';
        echo '</article>';
    }
    wp_reset_query();
    hui_paging();
}
Пример #3
0
 * Template Name: Likes Page
 * By daqianduan.com
*/
get_header();
?>
<div class="content-wrap">
	<div class="content page-likes no-sidebar">
		<h1 class="title"><strong><?php 
echo get_the_title();
?>
</strong></h1>
		<ul class="likepage">
		<?php 
$args = array('caller_get_posts' => 1, 'meta_key' => 'like', 'orderby' => 'meta_value_num', 'showposts' => 40);
query_posts($args);
while (have_posts()) {
    the_post();
    $count = hui_post_images_number();
    $like = get_post_meta(get_the_ID(), 'like', true);
    echo '<li><a href="' . get_permalink() . '">' . hui_get_thumbnail() . '<h2>' . get_the_title() . '</h2></a>', hui_get_post_like($class = 'post-like'), '<span class="img-count"><span class="glyphicon glyphicon-picture"></span>' . $count . '</span>', '</li>';
}
wp_reset_query();
?>
		</ul>
		<?php 
comments_template('', true);
?>
	</div>
</div>
<?php 
get_footer();
Пример #4
0
    }
    ?>
		<article class="article-content">
			<?php 
    the_content();
    ?>
		</article>
		<?php 
    wp_link_pages('link_before=<span>&link_after=</span>&before=<div class="article-paging">&after=</div>&next_or_number=number');
    ?>
		<?php 
}
?>
		<div class="article-social">
			<?php 
echo hui_get_post_like($class = 'action action-like');
?>
		</div>
		<div class="action-share bdsharebuttonbox">
			<?php 
echo __('分享到:', 'haoui');
?>
<a class="bds_qzone" data-cmd="qzone"></a><a class="bds_tsina" data-cmd="tsina"></a><a class="bds_weixin" data-cmd="weixin"></a><a class="bds_tqq" data-cmd="tqq"></a><a class="bds_sqq" data-cmd="sqq"></a><a class="bds_tpf" data-cmd="tpf"></a><a class="bds_renren" data-cmd="renren"></a><a class="bds_qq" data-cmd="qq"></a><a class="bds_diandian" data-cmd="diandian"></a><a class="bds_youdao" data-cmd="youdao"></a><a class="bds_ty" data-cmd="ty"></a><a class="bds_fbook" data-cmd="fbook"></a><a class="bds_twi" data-cmd="twi"></a>
			<a class="bds_more" data-cmd="more"><?php 
echo __('更多', 'haoui');
?>
</a>
			<a class="bds_count" data-cmd="count"></a>
		</div>
		<div class="article-tags">
			<?php 
Пример #5
0
            }
        }
        $focuscode = hui_get_thumbnail($imgSingle, false);
        $focuscode = $focuscode ? '<p class="focus"><a' . hui_target_blank() . ' href="' . get_permalink() . '" class="thumbnail">' . $focuscode . '</a></p>' : '';
    }
    $author = get_the_author();
    if (_hui('author_link')) {
        $author = '<a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . $author . '</a>';
    }
    $p_meta = _hui('post_plugin');
    echo '<article class="excerpt' . $classname . '">';
    echo '<header>';
    if (!is_category()) {
        $category = get_the_category();
        if ($category[0]) {
            echo '<a class="cat label label-important" href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '<i class="label-arrow"></i></a> ';
        }
    }
    echo '<h2><a' . hui_target_blank() . ' href="' . get_permalink() . '" title="' . get_the_title() . _hui('connector') . get_bloginfo('name') . '">' . get_the_title() . '</a></h2>';
    if ($img_number) {
        echo '<small class="text-muted"><span class="glyphicon glyphicon-picture"></span>' . $img_number . '</small>';
    }
    echo '</header>', '<p class="text-muted time">' . ($p_meta && $p_meta['siteauthor'] ? get_bloginfo('name') . ' - ' : '') . $author . ' ' . __('发布于', 'haoui') . ' ' . hui_get_post_date(get_gmt_from_date(get_the_time('Y-m-d G:i:s'))) . '</p>', $focuscode, '<p class="note">' . hui_get_excerpt_content() . '</p>', '<p class="text-muted views">';
    if (_hui('post_link_excerpt_s')) {
        hui_post_link();
    }
    echo hui_get_views(), $p_meta && $p_meta['comm'] ? '<span class="post-comments">' . hui_get_comment_number() . '</span>' : '', hui_get_post_like($class = 'post-like'), the_tags('<span class="post-tags">' . __('标签:', 'haoui'), ' / ', '</span>'), '</p>';
    echo '</article>';
}
hui_paging();
wp_reset_query();