WordPress页面内容阅读更多


WordPress Page content read more

编辑:

我有一个自定义的php函数设置来显示wordpress文章的摘录,当点击阅读更多链接时,摘录将被隐藏,并显示主要内容。然而,我希望"阅读更多"按钮成为内容展开时的隐藏按钮。

<?php the_excerpt();
echo '<a value="show more..." onclick="$(this).prev().hide(); $(this).next().show();" >Read More</a>';
echo '<div style="display:none">';
echo the_content();
echo '</div>'; ?>

为了保持简单,您可以执行以下操作:

<div id="shortcontent">
    <?php the_excerpt(); ?>
    <a href="javascript:void(0)" onclick="$('#shortcontent').hide();$('#fullcontent').show();">Read more</a>
</div>
<a href="javascript:void(0)"></a>
<div id="fullcontent" style="display: none">
    <?php the_content(); ?>
    <a href="javascript:void(0)" onclick="$('#fullcontent').hide();$('#shortcontent').show();">Hide</a>
</div>