Wordpress 在短代码中使用IF语句会破坏主题
我已经设置了一个带有多个选项的滑块短码,这是一个标题,使用自定义帖子类型的滑块的元框来提供选项,如是否显示标题、标题文本等。基本上在我使用的地方Wordpress 在短代码中使用IF语句会破坏主题,wordpress,shortcode,Wordpress,Shortcode,我已经设置了一个带有多个选项的滑块短码,这是一个标题,使用自定义帖子类型的滑块的元框来提供选项,如是否显示标题、标题文本等。基本上在我使用的地方 if ( $captionCheckbox !== '1') { 到 endif; $slider.=''; if和endif之间的一切都破坏了主题,但我不明白为什么,这里是完整的短代码,如果它有帮助的话 function ls_slider_shortcode( $atts, $content = null ) { $slider = '<
if ( $captionCheckbox !== '1') {
到
endif;
$slider.='';
if和endif之间的一切都破坏了主题,但我不明白为什么,这里是完整的短代码,如果它有帮助的话
function ls_slider_shortcode( $atts, $content = null ) {
$slider = '<section id="slider" class="flexslider container clearfix">';
$slider .= '<ul class="slides">';
$sliderQuery = "post_type=slider";
query_posts( $sliderQuery );
if ( have_posts() ) : while ( have_posts() ) : the_post();
$slideImage = get_the_post_thumbnail( $post->ID, 'slider');
$slider .= '<li>';
$slider .= $slideImage;
$captionCheckbox = get_post_meta( get_the_id(), 'ls_show_slider_caption', true);
$productCheckbox = get_post_meta( get_the_id(), 'ls_show_button_link', true);
$position = get_post_meta( get_the_id(), 'ls_caption_position', true);
$heading = get_post_meta( get_the_id(), 'ls_caption_heading', true);
$text = get_post_meta( get_the_id(), 'ls_caption_text', true);
$productLink = get_post_meta( get_the_id(), 'ls_project_link', true);
if ( $captionCheckbox !== '1' ) {
$slider .= '<div class="caption' . $position . '>';
$slider .= '<div class="body">';
$slider .= '<h2 class="caption-title">' . $heading . '</h2>';
$slider .= '<p>' . $text . '</p>';
$slider .= '</div>';
if ( $captionCheckbox !== '1' ) {
$slider .= '<a href="' . $productLink .'">View Project</a>';
}
endif;
$slider .= '</div>'
}
endif;
$slider .= '</li>';
endwhile; endif; wp_reset_query();
$slider .= '</ul>';
$slider .= '</section>';
return $slider;
}
add_shortcode('slider', 'ls_slider_shortcode');
函数ls\u slider\u shortcode($atts,$content=null){
$slider='';
$slider.='