###前提・実現したいこと
いつもお世話になっております。
WordPress Popular Postsプラグインを使ってランキングを表示させたいと考えてます。
イメージはこのサイトに近いです。
http://highfivecreate.com/faq
投稿画面のエディタは非表示にし、「Q.制作費用は〜」と「A.ご参考までに〜」をカスタムフィールドで追加しています。
アーカイブページに質問一覧を表示するので、参考サイトと同じレイアウトで
「Q. 質問」
「A. 回答」
「Q. 質問」
「A. 回答」
と順に並べて、投稿詳細ページ(single.php)へのリンクは設置していません。(投稿詳細ページに遷移させないようにするため)
ここまではできていますが、『Sorry. No data so far.』とメッセージが表示されます。
そもそも投稿詳細ページを閲覧しないようにしていてもランキングを表示させることができるのでしょうか?
解決策があればご教示いただければ幸いです。
###functions.php
function my_custom_popular_post( $post_html, $p, $instance ){ $custom_question = get_post_meta($p->id, 'question', true);//カスタムフィールド $custom_answer = get_post_meta($p->id, 'answer', true);//カスタムフィールド $custom_id= $p->id; $output = ' <div class="item"> <div class="question">'. $custom_question .'</div> <div class="answer">'. $custom_answer .'</div> </div> '; return $output; } add_filter( 'wpp_post', 'my_custom_popular_post', 10, 3 );
###archive.php
if (function_exists('wpp_get_mostpopular')){ $arg = array ( 'range' => 'daily',//集計の期間(daily,weekly,monthly) 'order_by' => 'avg',//集計方法(avg,views) 'stats_views' => '0',//閲覧数を表示(非表示0、表示1) 'post_type' => 'post',//ポストタイプ 'limit' => 5, //表示件数 'wpp_start' => '<div class="question-list">', // リストの開始タグ 'wpp_end' => '</div>', // リストの終了タグ ); wpp_get_mostpopular($arg); }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/10/15 08:21