Php WordPress在滑块中发布摘录
我想创建一个滑块,但无法使文章摘录正常工作。标题和permalink正在运行,但摘录不会显示。。。这是我的密码:Php WordPress在滑块中发布摘录,php,wordpress,post,slider,Php,Wordpress,Post,Slider,我想创建一个滑块,但无法使文章摘录正常工作。标题和permalink正在运行,但摘录不会显示。。。这是我的密码: // Args $args = array( 'cat' => $categories, 'post_type' => 'post', 'posts_per_
// Args
$args = array(
'cat' => $categories,
'post_type' => 'post',
'posts_per_page' => $amount,
);
// Our incrementing counter, leave this set to 0
$counter = 0;
// Query the posts based off of the parameters in the $args variable
$bs_posts = new WP_Query( $args );
// Our calculated limit of how many posts we have to work with, don't change this
$bs_posts_limit = count( $bs_posts->posts ) - 1;
// How many posts to display in each slide of the SlideDeck
$per_page = !empty($this->options['per-slide']) ? $this->options['per-slide'] : '2';
// Add "active" class to 1st slider item
$j=1;
// Carousel/Slider Html
echo "$tab<div" . (!empty($this->options['id']) ? ' id="slider-' . trim($thesis->api->esc($this->options['id'])) . '"' : '') . ' class="carousel slide'. (!empty($this->options['c-type']) ? ' ' . trim($thesis->api->esc($this->options['c-type'])) : '') .''. (!empty($this->options['class']) ? ' ' . trim($thesis->api->esc($this->options['class'])) : '') . "\" data-ride=\"carousel\">\n".
"$tab<h2 class=\"text-shadow\">". stripslashes($this->options['intro']) ."</h2>\n".
"$tab<div class=\"carousel-inner\">\n";
?>
<?php foreach( $bs_posts->posts as $bs_post ): ?>
<?php
// Variables
$slide_number = floor( $counter / $per_page ) + 1;
$slide_mod = $counter % $per_page;
$bs_post_ID = $bs_post->ID;
$bs_post_title = get_the_title( $bs_post_ID );
$bs_post_link = get_permalink( $bs_post_ID );
$bs_post_excerpt = get_the_excerpt( $bs_post_ID );
?>
<?php if( $slide_mod == 0 ): ?>
<div class="item <?php if($j <= 1) {echo 'active';} ?>">
<?php endif; ?>
<div class="single">
<?php if (has_post_thumbnail( $bs_post->ID )) the_post_thumbnail( 'thumbnail', array( 'title' => "#htmlcaption") ) ?>
<a href="<?php echo $bs_post_link; ?>"><?php echo $bs_post_title;?></a>
<?php echo $bs_post_excerpt; ?>
<a href="<?php echo $bs_post_link; ?>" class="btn btn-default btn-xs" style="float:right;">Read More</a>
</div>
<?php if( $slide_mod == ( $per_page - 1 ) || $counter == $bs_posts_limit ): ?>
</div>
<?php endif; ?>
<?php $counter++; $j++;?>
<?php endforeach; ?>
<?
echo "$tab</div>\n".
"$tab</div>\n";
?>
<?
//参数
$args=数组(
“cat”=>$categories,
“post_type”=>“post”,
“每页帖子数”=>$amount,
);
//我们的递增计数器,将此设置保留为0
$counter=0;
//根据$args变量中的参数查询帖子
$bs_posts=新的WP_查询($args);
//我们计算出的要处理多少个帖子的限制,不要改变这一点
$bs_posts\u limit=计数($bs_posts->posts)-1;
//在幻灯片的每个幻灯片中显示多少篇文章
$per_page=!空($this->options['per-slide'])$此->选项['per-slide']:'2';
//将“活动”类添加到第一个滑块项
$j=1;
//转盘/滑块Html
echo“$tab在查看文档后,我发现get_the_extract()没有post id参数。它必须在lop中使用
如果你想在循环之外获取摘录,你必须获取文章的全部内容,并自己将其截断。谢谢你的帮助。我已经成功地将其运行了。再次感谢。