wordpress popular postsプラグインがずっとSorry. No data so farと表示されます。
phpMyAdminに自動作成されるwp_popularpostsdataをみても、何もありません。
そこで思ったのが、記事をDBに送れていない可能性がある。
Ajaxを利用しているのですが、どうすればこのプラグインを使えるようになれますでしょうか?
<?php /* * Template Name: test_backnumber */ ?> <?php $count = 20; if (($_GET['c']) && (is_numeric($_GET['c']))) { if (($_GET['c'] > 0) && ($_GET['c'] <= 20)) { $count = $_GET['c']; } } header('Content-Type: application/json; charset='.get_option('blog_charset'), true); //-----[postのエントリー一覧取得] $args = array( 'range' => 'daily', 'limit' => 5, 'numberposts' => $count, 'offset' => 0, 'category' => null, 'orderby' => 'views', 'order' => 'ASC', 'include' => null, 'exclude' => null, 'meta_key' => 'category', 'meta_value' => null, 'post_type' => 'test', 'post_mime_type' => null, 'post_parent' => null, 'post_status' => 'publish' ); $posts = get_posts($args); $jsonAry = array(); foreach($posts as $post) : setup_postdata($post); $obj = new item(); $obj->id = $post->ID; $obj->title = $post->post_title; $obj->date = get_post_time('Y.m.d', true); $obj->category = get_post_meta($post->ID, 'category', true); $obj->lead = str_replace("\r\n", "</br>", get_post_meta($post->ID, 'lead', true)); $imgPost = get_post(get_post_meta($post->ID, 'main_v_1', true)); $obj->img = $imgPost->guid; $obj->caption = $imgPost->post_excerpt; array_push($jsonAry, $obj); endforeach; echo json_encode($jsonAry); update_views_ajax(); //------------------------------ // JSONアイテム //------------------------------ class item { public $id; public $title; public $date; public $category; public $lead; public $img; public $caption; } ?>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。