Php Wordpress查询仅包括具有特定内容的帖子
我希望此查询仅在包含来自geodir_special_Offices的文章和文本时显示帖子echoPhp Wordpress查询仅包括具有特定内容的帖子,php,wordpress,posts,Php,Wordpress,Posts,我希望此查询仅在包含来自geodir_special_Offices的文章和文本时显示帖子echo <?php global $post; $args = array( 'posts_per_page' => 4 , 'post_type' => 'gd_arts',); $lastposts = get_posts( $args ); foreach ( $lastposts as $post ) : setup_postdata( $post ); ?>
<?php
global $post;
$args = array(
'posts_per_page' => 4 , 'post_type' => 'gd_arts',);
$lastposts = get_posts( $args ); foreach ( $lastposts as $post ) : setup_postdata( $post ); ?>
<h2><a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a></h2>
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail(array(486,226));
} ?>
<php echo $post->geodir_special_offers; ?>
<?php endforeach;
wp_reset_postdata();
?>
geodir_特别优惠;?>
我是新来的,所以请容忍我
如果不是100%结构化,请提前道歉。试试这个!它会在回复内容之前检查是否设置了特别优惠。希望这就是你想要的
<?php
global $post;
$args = array(
'posts_per_page' => 4 , 'post_type' => 'gd_arts',);
$lastposts = get_posts( $args );
foreach ( $lastposts as $post ) {?>
<?php if(strlen ($post->geodir_special_offers) > 5){ ?>
<h2><a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a></h2>
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail(array(486,226));
}
}
}
wp_reset_postdata();
?>