希望一切顺利。我编写了一个小部件,它显示来自自定义帖子类型“Staff”的帖子。每当客户添加新员工时,都会显示他们的姓名和特征图像。我的问题是:如何让这些“帖子”填充列?理想情况下,我希望有2行4列。以下是我的小部件代码:
public function widget($args, $instance) {
//Arguments that you can pass through the widget function. We are displaying only the CPT \'News\' in our widget
$args = array(
\'post_type\' => \'Staff\',
\'posts_per_page\' => -1,
);
//Loop through Custom Post Type in there are posts and if we are currently on a single Program page. (\'program\' must be lowercase) EDIT is_singular is now empty to show on all singular pages in general
$loop = new WP_Query($args);
if($loop->have_posts() && is_singular(\'\')):
while($loop->have_posts()) {
$loop->the_post();
//What will be displayed physically in the widget for each item
echo \'<br />\';
the_title();
echo \'<div class="entry-content">\';
the_post_thumbnail(\'thumbnail\');
the_content();
echo \'</div>\';
}endif;
wp_reset_postdata();
}
任何帮助都将不胜感激!