我想添加滑块短代码。“我的所有滑块”字段正确地添加到快捷码中,但未显示“阅读更多”按钮和按钮链接。你能解决我的问题吗?这是我的滑块代码:
<section id="firstsection">
<div class="container-fluid">
<div class="col-xs-12 firstsection-maindiv">
<?php
$slide = array( \'post_type\' => \'slider\' ,);
$slider_query = new WP_Query( $slide );
?>
<?php
if( have_posts() ) : while($slider_query->have_posts() ) : $slider_query->the_post();
?>
<div id="explore-section" class="owl-carousel owl-theme">
<div class="item">
<div class="col-xs-12 firstsection-innerdiv">
<div class="col-lg-6 col-md-6 col-xs-6 col-sm-6 firstsection-inner-left-div">
<p class="oneplace"><?php echo get_the_title(); ?></p>
<p class="slider-content"><?php echo get_the_content(); ?></p>
<?php $buttonname = get_post_meta($post->ID, "wp_producer_name" , true) ?>
<?php $buttonlink = get_post_meta($post->ID, "wp_button_link" , true) ?>
<button class="slider-btn" type="button"><a href="<?php echo $buttonlink ; ?>"> <?php echo $buttonname ; ?></a></button>
</div>
<div class="col-lg-6 col-md-6 col-xs-6 col-sm-6 firstsection-inner-right-div">
<?php echo get_the_post_thumbnail(); ?>
</div>
</div>
</div>
</div>
<?php endwhile; endif; ?>
</div>
</div>
</section>
这是我的短代码:
// Add Shortcode
add_shortcode( \'valute-slider-shortcode\', \'display_custom_post_type\' );
function display_custom_post_type(){
$args = array(
\'post_type\' => \'Slider\',
\'post_status\' => \'publish\'
);
$string = \'\';
$query = new WP_Query( $args );
if( $query->have_posts() ){
$string .= \'<section id="firstsection">\';
while( $query->have_posts() ){
$query->the_post();
$buttonname = get_post_meta($post->ID, "wp_producer_name" , true);
if( !empty($buttonname) ): endif;
$string .= \'<div class="container-fluid">\' .
\'<div class="col-xs-12 firstsection-maindiv">\' .
\'<div id="explore-section" class="owl-carousel owl-theme">\' .
\'<div class="item">\' .
\'<div class="col-xs-12 firstsection-innerdiv">\' .
\' <div class="col-lg-6 col-md-6 col-xs-6 col-sm-6 firstsection-inner-left-div">\' .
\' <p class="oneplace">\' .get_the_title() . \'</p>\'.
\' <p class="slider-content">\' .get_the_content() . \'</p>\'.
\' <button class="slider-btn" type="button">\' . $buttonname . \'</button>\'.
\'</div>\' . \' <div class="col-lg-6 col-md-6 col-xs-6 col-sm-6 firstsection-inner-right-div">\' . get_the_post_thumbnail() . \'</div>\' .
\'</div>\' .
\'</div>\' .
\'</div>\' .
\'</div>\';
}
$string .= \'</section>\';
}
wp_reset_postdata();
return $string;