我在wordpress主题中创建了一个自定义帖子类型,专门为主页上显示的滑块创建幻灯片,它有标题、幻灯片文本、幻灯片url以及特色图像。
我现在正试图从自定义帖子类型中的元框中获取此信息,并将其转换为一个滑块,该滑块显示的幻灯片数量与帖子数量相同。
目前,我输出的代码有点混乱,所发生的一切就是显示了特征图像,但不在正确的位置,也不带文本等。
以下是我的php代码:
<section id="intro" class="main fullscreen">
<div class="slider-wrapper">
<div id="header_slider" class="owl-carousel owl-theme">
<?php $loop = new WP_Query( array( \'post_type\' => \'slider\', \'posts_per_page\' => -1 ) );?>
<?php while ( $loop->have_posts() ) : $loop->the_post();?>
<?php
$slide_text = get_post_meta($post->ID, "_text", true);
$slide_url = get_post_meta($post->ID, "_url", true);
$slide_img = the_post_thumbnail();
?>
<div class="item slider-info" style="background-color:#3498db;">
<div class="text-slider">
<p><?php echo $slide_text; ?></p>
<a href="<?php echo $slide_url; ?>" id="scroll_to">
<span class="scroll-down">
<span class="fa fa-angle-down"></span>
</span>see what we can do for you.</a>
</div>
<?php echo $slide_img; ?>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
</div>
</section>
这将在我的HTML中返回以下内容:
<section id="intro" class="main fullscreen">
<div class="slider-wrapper">
<div id="header_slider" class="owl-carousel owl-theme">
<img width="1230" height="620" src="http://resurrectiongroup.thedistractionsband.co.uk/wp-content/uploads/2014/05/slider-4.jpg" class="attachment-post-thumbnail wp-post-image" alt="slider-4" /><div class="item slider-info" style="background-color:#3498db;">
<div class="text-slider">
<p></p>
<a href="#" id="scroll_to">
<span class="scroll-down">
<span class="fa fa-angle-down"></span>
</span>see what we can do for you.</a>
</div>
</div>
<img width="1230" height="620" src="http://resurrectiongroup.thedistractionsband.co.uk/wp-content/uploads/2014/05/slider-1.jpg" class="attachment-post-thumbnail wp-post-image" alt="slider-1" /><div class="item slider-info" style="background-color:#3498db;">
<div class="text-slider">
<p>#about</p>
<a href="#" id="scroll_to">
<span class="scroll-down">
<span class="fa fa-angle-down"></span>
</span>see what we can do for you.</a>
</div>
</div>
</div>
</div>
</section>
我不知道我做错了什么,我肯定这与我如何设置循环有关,但我不确定从哪里开始寻找。任何帮助都将不胜感激