gpt4 book ai didi

php - 阅读更多使用 js 发布 wordpress

转载 作者:行者123 更新时间:2023-11-30 05:47:33 25 4
gpt4 key购买 nike

嗨,我想用 js 添加阅读更多内容,当点击阅读更多内容时,它将显示有限的内容,它将在同一页面上显示完整的帖子

下面是我使用的代码

     <?php if ( have_posts() ) : ?>

<?php /* Start the Loop */ ?>
<?php
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
query_posts( array( 'post_type' => 'post' , 'posts_per_page' => '3' ) );
?> <?php while ( have_posts() ) : the_post(); ?>
<div class="post-box img-polaroid row">
<h3 class="title-post text-left span3"><?php the_title(); ?></h3>

<div class="post-par span6 text-left"><?php the_content();?></div>

<span class="span3 offset3 text-center" style="width:100%; margin:0px;">
<button class="hear-more"></button>

</span>
</div>
<?php endwhile; ?>
<?php endif; ?>`

当一些点击阅读更多它会显示完整的帖子......

最佳答案

使用 php 限制发布者:

$length_limit = 1000; //character
echo '<div class="summaryarticle">';
echo mb_substr(the_content(), 0, $length_limit);
echo '</div>';

echo '<input type="button" value="show more..." onclick="$(this).prev().hide(); $(this).next().show();" />';

echo '<div class="fullarticle" style="display:none">';
echo the_content();
echo '</div>';

注意使用页面必须包含jquery。也许是这样。

关于php - 阅读更多使用 js 发布 wordpress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17132087/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com