Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress查询仅包括具有特定内容的帖子_Php_Wordpress_Posts - Fatal编程技术网

Php Wordpress查询仅包括具有特定内容的帖子

Php 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 ); ?>

我希望此查询仅在包含来自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 ); ?>

<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(); 
?>