Php 希望基于Visual composer(WPBakery)中的自定义帖子类型类别缩小数据源范围
我有一个定制的“小屋”类型,分类为(1张床、2张床、3张床) 我可以使用my functions.php中的以下vc_映射获得要在Visual Composer中显示的元素:Php 希望基于Visual composer(WPBakery)中的自定义帖子类型类别缩小数据源范围,php,wordpress,custom-post-type,visual-composer,Php,Wordpress,Custom Post Type,Visual Composer,我有一个定制的“小屋”类型,分类为(1张床、2张床、3张床) 我可以使用my functions.php中的以下vc_映射获得要在Visual Composer中显示的元素: // Cottages List if(function_exists('vc_map')){ vc_map( array( "name" => __("My Cottages List", 'archi'), "base" => "cottageslist", "class" =>
// Cottages List
if(function_exists('vc_map')){
vc_map( array(
"name" => __("My Cottages List", 'archi'),
"base" => "cottageslist",
"class" => "",
"category" => 'My Elements',
"icon" => "icon-rtcvc",
"params" => array(
array(
"type" => "textfield",
"holder" => "div",
"class" => "",
"heading" => "Show how many cottages per page?",
"param_name" => "number",
"value" => "",
"description" => __("Add Number -1 for show all post.", 'archi')
),
)
));
}'
然后,我知道它会显示以下php/html代码(这也会错开功能图像、文章内容……文章内容、功能图像的行)
//小屋列表开始
添加_快捷码('cottageslist','cottageslist_func');
函数cottageList_func($atts,$content=null){
提取(短码)附件(数组)(
'编号'=>'',
)美元(附件);;
$number1=(!空($number)?$number:4);
ob_start();
?>
// Cottages List start
add_shortcode('cottageslist','cottageslist_func');
function cottageslist_func($atts, $content = null){
extract(shortcode_atts(array(
'number' => '',
), $atts));
$number1 = (!empty($number) ? $number : 4);
ob_start();
?>
<?php
$i = 0;
$args = array(
'post_type' => 'cottages',
'posts_per_page' => $number1,
);
$cottages = new WP_Query($args);
if($cottages->have_posts()) : while($cottages->have_posts()) : $cottages->the_post(); $i++;
?>
<section class="side-bg no-padding service-list" id="section-service-<?php echo esc_attr($i); ?>">
<?php if ($i % 2 == 1) { ?>
<div class="image-container col-md-5 pull-left" data-delay="0">
<div class="background-image" style="background-image:url('<?php the_post_thumbnail_url( 'full' ); ?>');"></div>
</div>
<div class="container">
<div class="row">
<div class="inner-padding">
<div data-wow-delay=".5s" class="col-md-6 col-md-offset-6 wow fadeInRight">
<h3 class="id-color"><a class="" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
<div class="spacer-single"></div>
<a class="btn-line" href="<?php the_permalink(); ?>"><?php _e('Read More', 'archi') ?></a>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<?php }else{ ?>
<div data-delay="0" class="image-container col-md-5 col-md-offset-7 pull-right right0">
<div class="background-image" style="background-image:url('<?php the_post_thumbnail_url( 'full' ); ?>');"></div>
</div>
<div class="container">
<div class="row">
<div class="inner-padding">
<div data-wow-delay=".5s" class="col-md-6 wow fadeInLeft">
<h3 class="id-color"><a class="" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
<div class="spacer-single"></div>
<a class="btn-line" href="<?php the_permalink(); ?>"><?php _e('Read More', 'archi') ?></a>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<?php } ?>
</section>
<?php endwhile; wp_reset_postdata(); endif; ?>
<?php
return ob_get_clean();
}
// Cottages List start