我有一个自定义的'Cottages'类型,有类别(1张床,2张床,3张床)。
我可以在我的functions.php中使用以下vc_map在Visual Composer中显示一个元素:
// 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代码(也会错开特征图像行,发布内容...发布内容,功能图像)
// 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
这是我完全迷失的地方!:
帮助!我一直在用我能找到的任何可能有帮助的代码进行切割粘贴技巧,经过一天的努力,我仍然失败了!
是的,我知道VC Post Grid元素会过滤得很好,但是我不喜欢前端的那些Post Grid块在页面其余部分完全加载后仅加载几秒钟。 / p>
由于 JD