WordPress Popular Posts - yagisawatakuya/Wiki GitHub Wiki
出力例
<?php
$args = array(
'range' => 'all',
'order_by' => 'views',
'post_type' => 'article',
'stats_comments' => '0',
'limit' => 3,
'stats_views' => '0',
'wpp_start' => '<div class="ranking">',
'wpp_end' => '</div>',
);
wpp_get_mostpopular($args);
?>
function.php カスタムズ例
function my_custom_single_popular_post( $post_html, $p, $instance ){
$ttl = get_the_title( $p->id );
$img = get_field( 'mainvisual', $p->id );
$imgurl = wp_get_attachment_image_src( $img, 'large' );
$thumb = '<img src="'.$imgurl[0].'" alt="">';
$output = '<a class="item" href="' . get_the_permalink($p->id) . '"><article class="siteRankingArticle"><div class="thumb">' . $thumb . '<span class="rank"></span></div><h1 class="heading">' . $ttl . '</h1></article></a>';
return $output;
}
if ( !is_admin() ) add_filter( 'wpp_post', 'my_custom_single_popular_post', 10, 3 );