Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.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 后期缩略图图像显示在父div之外_Php_Html_Wordpress - Fatal编程技术网

Php 后期缩略图图像显示在父div之外

Php 后期缩略图图像显示在父div之外,php,html,wordpress,Php,Html,Wordpress,我在主页上显示最近的文章,我使用下面的代码。现在的问题是,我正在从父div中获取所有post图像,并且内容显示正确。我得到的输出像 电流输出示例 <div class="entry-content"> <img> <img> <img> <div class="cp-seeWrapper"> <div class="row"><div class="col"> //my content are displayin

我在主页上显示最近的文章,我使用下面的代码。现在的问题是,我正在从父div中获取所有post图像,并且内容显示正确。我得到的输出像

电流输出示例

<div class="entry-content">
<img>
<img>
<img>
<div class="cp-seeWrapper">
<div class="row"><div class="col">
//my content are displaying here which is correct
</div>
</div>
</div>
</div>
post\u缩略图()

与结果相呼应。您应该使用
获取帖子缩略图()

干杯

发布缩略图()

与结果相呼应。您应该使用
获取帖子缩略图()


干杯

哦!!是的,在使用您的答案后,它就开始工作了……那么_category()呢?我在分类中得到了相同的问题。我将其从\u category()更改为获取\u the \u category(),但我正在获取数组输出。如果我添加任何内容,那么它也会显示在父div之外。现在我尝试在col-4中显示,它显示在父div的上方。获取\u the \u category()返回一个WP\u术语数组。为了显示第一次使用,请获取\u类别[0]->名称。并将\u permalink更改为esc\u url(获取\u permalink()),我尝试获取\u类别[0]->名称,但它没有显示任何内容。我更新了问题中的代码。现在我得到了分类。但是如果我使用$categories[0]->name,那么我只能得到一个categry名称。。我有一个单一的产品超过1类上市。哦!是的,在使用您的答案后,它就开始工作了……那么_category()呢?我在分类中得到了相同的问题。我将其从\u category()更改为获取\u the \u category(),但我正在获取数组输出。如果我添加任何内容,那么它也会显示在父div之外。现在我尝试在col-4中显示,它显示在父div的上方。获取\u the \u category()返回一个WP\u术语数组。为了显示第一次使用,请获取\u类别[0]->名称。并将\u permalink更改为esc\u url(获取\u permalink()),我尝试获取\u类别[0]->名称,但它没有显示任何内容。我更新了问题中的代码。现在我得到了分类。但是如果我使用$categories[0]->name,那么我只能得到一个categry名称。。我有一个以上的产品类别上市。
 function recentPost_on_home(){
$data='<div class="cp-seeWrapper"><div class="container"><div class="row"><div class="col-xl-8 col-lg-8 col-md-8 col-sm-12 col-xs-12"><div class="row">';
            $args = array('posts_per_page' => 5, 'nopaging' => true);
            // set up new query
            $tyler_query = new WP_Query( $args );
            // loop through found posts
            if ($tyler_query->have_posts()) {
                while ( $tyler_query->have_posts() ) {
          $tyler_query->the_post();
          $categories = get_the_category();
          if ( ! empty( $categories ) ) {
          $cat_list= esc_html( $categories[0]->name );   
            }
          $data.= '<div class="col-xl-6 col-lg-6 col-md-6 col-sm-12 col-xs-12">
          <div class="cp-shadow cp-seeSinglePostWrapper">
          '.get_the_post_thumbnail().'<div class="bg-white single-post-box">
               <div class="d-flex cp-CategoryList">
               <div class="seeDate">'.get_the_date('F j, Y').'</div>'.$cat_list.'</div>
    <a href="'.esc_url( get_the_permalink() ).'" title="'.esc_attr( the_title_attribute( 'echo=0' ) ).'" class="seePost_title">'.wp_trim_words(get_the_title(), 10, '...').'</a>
      <p>'.wp_trim_words(get_the_excerpt(), 20, '...').'</p>
  </div>
              </div>
                        </div>';

        }
      }
  $data.='</div></div>';
  $data.='<div class="col-xl-4 col-lg-4 col-md-4 col-sm-12 col-xs-12"><div class="cp-social cp-shadow bg-white"><h3>Social</h3>';
            if (is_active_sidebar('footer-social')) :
                 dynamic_sidebar('footer-social');
                endif;
  $data.='</div></div></div></div>';
 return $data;    
}
add_shortcode( 'home_recent_post', 'recentPost_on_home' );