wordpressでアクセス数を表示させたくて調べた結果、
function.phpに
//アクセス数の取得
function get_post_views( $postID ) {
$count_key = 'post_views_count';
$count = get_post_meta( $postID, $count_key, true );
if ( $count == '' ) {
delete_post_meta( $postID, $count_key );
add_post_meta( $postID, $count_key, '0' );
return "0 views";
}
return $count . '';
}
//アクセス数の保存
function set_post_views( $postID ) {
$count_key = 'post_views_count';
$count = get_post_meta( $postID, $count_key, true );
if ( $count == '' ) {
$count = 0;
delete_post_meta( $postID, $count_key );
add_post_meta( $postID, $count_key, '0' );
} else {
$count ++;
update_post_meta( $postID, $count_key, $count );
}
}
single.phpに
を入れれば表示されると知りやってみたのですが、前のテーマだと表示されたのですが今のテーマ【Luxeritas】だと表示されません。
なぜでしょう?
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。