我想显示已定义的帖子,但get\\u posts显示当前帖子,而不使用args中的定义。为什么,如何解决?get\\u posts和wp query之间有什么区别?谢谢
add_action( \'template_redirect\', \'check_shop\' );
function check_shop()
{
if (is_shop() ) {
$args1 = array(
\'post_author\' => \'admin\',
\'post_type\' => \'page\',
);
$post_types1 = get_posts( $args1, \'objects\' );
foreach ($post_types1 as $post_type1) {
setup_postdata( $post_type1 );
if (!empty($post_type1->post_content)) {
add_action(\'woocommerce_before_shop_loop_item_title\', function() {
global $post_type1;
the_title();
echo get_the_title($post_type1->ID);
echo $post_type1;
echo $post_type1->post_content;
echo "denemeee yazısı";
}, 1);
}
}
wp_reset_postdata();
}
}