Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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 如何将选中并突出显示的帖子从其他帖子中排除_Php_Wordpress_Foreach - Fatal编程技术网

Php 如何将选中并突出显示的帖子从其他帖子中排除

Php 如何将选中并突出显示的帖子从其他帖子中排除,php,wordpress,foreach,Php,Wordpress,Foreach,我有定制的医生职位类型。单击名称后,将转到医生的单个页面。下面是一个小div,其中显示了许多帖子。我不希望已经在顶部显示的帖子在底部 这是我所做的代码: <?php foreach($dr as $doc){ ?> <div class="col-md-4"> <img src="<?php echo get_the_post_thumbnail_url($doc->ID);?>" class

我有定制的医生职位类型。单击名称后,将转到医生的单个页面。下面是一个小div,其中显示了许多帖子。我不希望已经在顶部显示的帖子在底部

这是我所做的代码:

<?php foreach($dr as $doc){ ?>
            <div class="col-md-4">
                <img src="<?php echo get_the_post_thumbnail_url($doc->ID);?>" class="img-reposive img-circle dc-img mb50" alt="" />
            </div>
            <div class="col-md-8">
                <div class="dr-single-box">
                    <h3 class="dr-single-tile"><?php echo $doc->post_title; ?></h3>
                    <div class="sub-tile"><?php echo get_post_meta($doc->ID,'Department',true); ?></div>
                    <div class="dc-single-social">
<p><?php echo $doc->post_content; ?></p>
                    <a href="appointment" class="btn btn-default mt30 mb50">make an appointment</a>
                    <div class="row">
                        <div class="col-md-4">
                            <h3 class="mb10">Qualifications</h3>
                            <p><?php echo get_post_meta($doc->ID,'Qualifications',true); ?></p>        
                        </div>

ID);?>“class=”img reposive img circle dc img mb50“alt=”“/>

资格

底部部分如下所示:

<?php $arg=array('post_type'=>'doctors','post_status'=>'publish','posts_per_page'=>4,'offset'=>1) ;
$doctor_data=get_posts($arg); 
/*var_dump($doctor_data);*/ ?>
<div class="lightbg ptb80">
    <div class="container">
        <div class="row">
            <div class="col-lg-12 col-md-12">
                <h1 class="heading-title">Doctors</h1>
            </div>
        </div>
        <div class="row">
        <?php foreach($doctor_data as $doctor) { ?>
            <div class="col-lg-3 col-md-3">
                <div class="dc-style-box">
                   <img src="<?php echo get_the_post_thumbnail_url($doctor->ID); ?>" class="img-responsive" alt="Doctor 1" />
                    <div class="dc-style-inner">
                        <ul>
                            <li><a href="facebook.com"><i class="fa fa-facebook"></i></a></li>
                            <li><a href="facebook.com"><i class="fa fa-twitter"></i></a></li>
                            <li><a href="facebook.com"><i class="fa fa-google-plus"></i></a></li>
                        </ul> 
                        <h5><a href="<?php echo $doctor->guid; ?>"><?php echo $doctor->post_title; ?></a></h5>
                        <span><?php echo get_post_meta($doctor->ID,'Department',true);?></span>
                    </div>
                </div>
            </div>

医生
ID);?>“class=”img responsive“alt=”Doctor 1“/>
有人能给我点启示吗


<?php 
$cur = get_the_ID();
$arg=array('post_type'=>'doctors','post_status'=>'publish','posts_per_page'=>4,'offset'=>1, 'post__not_in' => $cur) ;
$doctor_data=get_posts($arg); 
/*var_dump($doctor_data);*/ ?>
<div class="lightbg ptb80">
    <div class="container">
        <div class="row">
            <div class="col-lg-12 col-md-12">
                <h1 class="heading-title">Doctors</h1>
            </div>
        </div>
        <div class="row">
        <?php foreach($doctor_data as $doctor) { ?>
            <div class="col-lg-3 col-md-3">
                <div class="dc-style-box">
                   <img src="<?php echo get_the_post_thumbnail_url($doctor->ID); ?>" class="img-responsive" alt="Doctor 1" />
                    <div class="dc-style-inner">
                        <ul>
                            <li><a href="facebook.com"><i class="fa fa-facebook"></i></a></li>
                            <li><a href="facebook.com"><i class="fa fa-twitter"></i></a></li>
                            <li><a href="facebook.com"><i class="fa fa-google-plus"></i></a></li>
                        </ul> 
                        <h5><a href="<?php echo $doctor->guid; ?>"><?php echo $doctor->post_title; ?></a></h5>
                        <span><?php echo get_post_meta($doctor->ID,'Department',true);?></span>
                    </div>
                </div>
            </div>
医生 ID);?>“class=”img responsive“alt=”医生1“/>
您好,您应该在中添加“
post\u not\u”,以排除要在第二个循环中提取的当前帖子。请尝试此代码。如果您需要更多帮助,请告诉我

谢谢。


医生
ID);?>“class=”img responsive“alt=”Doctor 1“/>
您好,您应该在
中添加“
post\u not\u”,以排除要在第二个循环中获取的当前帖子。试试这个代码。如果你需要更多的帮助,请告诉我


谢谢。

根据您的评论,您希望显示随机帖子,因此请在$arg下方使用,而不是您的

$arg = array('post_type'=>'doctors',
        'post_status'=>'publish',
        'posts_per_page'=>4,
        'offset'=>1,
        'orderby'   => 'rand'
      );

根据您的评论,您希望显示随机帖子,因此请使用下方$arg,而不是您的

$arg = array('post_type'=>'doctors',
        'post_status'=>'publish',
        'posts_per_page'=>4,
        'offset'=>1,
        'orderby'   => 'rand'
      );

那么,您是否希望在底部部分显示随机帖子?是,来自相同帖子类型的随机帖子。那么,您是否希望在底部部分显示随机帖子?是,来自相同帖子类型的随机帖子