1行のみを表示するはずのこのコードがありますが、最初の行のみを表示する代わりに、完全なコンテンツを表示します。「もっと見る」ボタンをクリックすると、サイドが一番上までスクロールします。
PHP:
/* Inside a loop */
<?php
$full_text = get_the_content();
$period_pos = strpos($full_text, ".");
$excerpt = substr($full_text, 0, $period_pos+1); // Get the first line, assuming that a line ends with a period.
$rest = substr($full_text, $period_pos+1); // Get the rest of the text ?> <div class="excerpt">
<?php echo $excerpt; ?> </div> <div class="rest">
<?php echo $rest; ?> </div> <div class="show-more-div">
<a href="#" class="show-more">Show more</a> </div>
jQuery:
$(document).ready(function(){
$(".show-more").click(function(){
$(this).parent().prev().slideDown();
});
});