0
내 개인 WordPress 테마에 대한이 코드를 사용하여 한 개의 사용자 정의 페이지에 인기있는 게시물을 표시하려고합니다. 불행히도 3 개의 모든 UL 블록에 동일한 게시물을 표시합니다. 아이디어는 3 일 동안 가장 많이 본 게시물을 표시 한 다음 다른 블록에서 7 일 동안 가장 많이 본 게시물을 표시하고 마지막으로 30 일 이내에 가장 많이 본 블로그를 표시합니다. 나는 지금 왜 일하지 않는가.조회수, 3 일, 7 일, 30 일간 인기 게시물
// Top post by views in last 3 day's
<ul>
<?php
function filter_where($where = '') {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-3 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts('post_type=post&posts_per_page=5&orderby=post_views_count&order=DESC');
while (have_posts()): the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php
endwhile;
wp_reset_query();
?>
</ul>
// Top post by views in last 7 day's
<ul>
<?php
function filter_where2($where = '') {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-7 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where2');
query_posts('post_type=post&posts_per_page=5&orderby=post_views_count&order=DESC');
while (have_posts()): the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php
endwhile;
wp_reset_query();
?>
</ul>
// Top post by views in last 30 day's
<ul>
<?php
function filter_where3($where = '') {
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where3');
query_posts('post_type=post&posts_per_page=5&orderby=post_views_count&order=DESC');
while (have_posts()): the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr('Permalink to %s'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php
endwhile;
wp_reset_query();
?>
</ul>
이것은 작동하지 않습니다. 하지만 고마워. – bulldozer
게시물 조회수를 계산하는 메타가 있습니까? 새로운 WP_Query로 query_posts를 변경 했습니까? – Benoti
불행히도, 모르겠다. WP의 새로운 기능. – bulldozer