简体   繁体   中英

WordPress Page content read more

EDIT:

I have a custom php function setup to show the wordpress post excerpt and when the read more link is clicked the excerpt is hidden and the main content displayed. However i want the read more button to become a hide button for when the content is expanded.

<?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>'; ?>

to keep it simple, you can do something like this:

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM