当我单击div时,我找不到权限参数来只显示一个类别的一篇文章。我用Ajax调用该文章,并将其显示在div弹出窗口中。也许这些论点是不够的,或者问题来自另一个方面?但当我在循环中回显get\\u the\\u id时,它是帖子的正确id。但是,它会显示类别中的所有帖子。另一个问题是,如果我没有指定类别(名称或id),它会显示Wordpress的所有帖子。这两个问题只有在我调用Ajax中的帖子时才会出现。
function more_content() {
$the_post_id = the_ID(); // $_POST[\'the_ID\'];
$args = array(
\'post_type\' => \'post\',
\'category_name\' => \'materials\',
\'p\' => $the_post_id
);
$ajax_query = new WP_Query($args);
$the_excerpt;
$the_content;
if ( $ajax_query->have_posts() ) : while ( $ajax_query->have_posts() ) : $ajax_query->the_post();
$the_excerpt = the_excerpt();
$the_content = the_content();
endwhile;
endif;
echo $the_excerpt;
echo "<div style=\'color:white; font-size:40px;\'>",$the_post_id,"</div>";
echo $the_content;
wp_reset_postdata();
die();
}