no-image

WordPressのアーカイブページでアクセス数順に表示するためのコード

[post_status draft]
post_views_countを設定した前提。
archiveページなどで、アクセス数順に表示したい場合のコード。

<?php
global $wp_query;
$args = array( ‘post_type’ => array(‘post’,’paint’,’review’,’vendor’) ); $post_type = get_query_var(‘post_type’);
if ($post_type == ‘vendor’) {
$args = array_merge( array(
‘meta_key’ => ‘post_views_count’,
‘orderby’ => ‘meta_value_num’,
‘order’ => ‘desc’
),$args
);
}
query_posts(array_merge(
$args ,
$wp_query->query
));
>

pocketlinehatebuimagegalleryaudiovideocategorytagchatquotegoogleplusfacebookinstagramtwitterrsssearchenvelopeheartstaruserclosesearch-plushomeclockupdateeditshare-squarechevron-leftchevron-rightleafexclamation-trianglecalendarcommentthumb-tacklinknaviconasideangle-double-upangle-double-downangle-upangle-downstar-halfstatus