0
を返します。しかし、が管理者としてとしてログアウトした場合、すべてがであり、細かい作業はです。Wordpressのは、0
誰かが私のような類似の問題を抱えている可能性がありますか?
adminとしてログインしてログアウトすると、出力が返されます(もちろん0ではありません)。
これはfunction.phpの関数です。
add_action('wp_ajax_nopriv_get_category_data', 'getCategoryData');
add_action('wp_ajax_load_get_category_data', 'getCategoryData');
function getCategoryData()
{
$data = [
'category' => htmlspecialchars($_POST['category'])
];
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'post_type' => 'Coupons',
'posts_per_page' => 8,
'post_status' => 'publish',
'paged' => $paged,
'rewrite' => array('slug' => 'CustomCat'),
'caller_get_posts'=> 1
);
$couponBlock = new WP_Query($args);
if ($data['category']) {
$the_query = new WP_Query(array ('cat' => $data['category'], 'posts_per_page' => 8));
if ($the_query->have_posts()):
while ($the_query->have_posts()): $the_query->the_post();
get_template_part('template/ajaxCustomCat', 'page');
endwhile;
wp_die();
endif;
} else {
return 'no data';
}
}
ねえ。私は自分の機能でトピックを更新しました。ご覧のとおり、私はすでにこのadd_action()を持っています。私のコードにはどんな問題がありますか? – xoomer
@xoomer私は私の答えを更新しました – acupajoe
ねえ、ありがとう!私は問題を修正しました。 – xoomer