• Resolved fogofogo

    (@fogofogo)


    Hello,

    I have a few static pages where I pull in the latest 3 posts. I am using the following code to achieve this…

    <?php } ?>
    <?php $my_query = new WP_Query(‘cat=3&showposts=1’); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <p class=”post”>
    <h2>
    <?php the_title(); ?></h2>
    </p>
    <div class=”entry”>
    <div class=”innerpost”><p>
    <?php the_content(); ?>
    <?php _e(‘Filed under:’); ?> <?php the_category(‘, ‘) ?> on <?php the_time(‘F jS, Y’) ?> <?php _e(‘by’); ?> <?php the_author(); ?>
    <?php comments_popup_link(‘No Comments ?’, ‘1 Comment ?’, ‘% Comments ?’); ?> <?php edit_post_link(‘Edit’, ‘ | ‘, ”); ?>

    But the code pulls in the entire post, even though I have a ‘read more’ break in the post. I was hoping to display a few lines then the read more link. Any ideas how I can get it to work. Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You could just make a link to the post somewhere for example add the following line under <?php the_content(); ?>:

    <a href="<?php the_permalink(); ?>">Read more</a>

    Hope this will help.

    Greetz,

    Durgé
    Dimics.com

    Thread Starter fogofogo

    (@fogofogo)

    Thank your for your reply.

    That has added a link, but it still hasn’t solved my problem with the ‘read more’ tag. Is there code missing that looks for a ‘read more’ tag perhaps and stop displaying the text until then? Instead of displaying all of the text?

    The more tag only default only works on the homepage. But there is a fix:
    https://wphackr.com/read-more-link-on-wordpress-pages/

    You could also just use the_excerpt(), this will show a limited number of words (55) or show the text you’ve put in the Excerpt panel on the post edit page.

    Durgé
    Dimics.com

    Thread Starter fogofogo

    (@fogofogo)

    Champion!!!! Thats exactly what I was after.

    Cheers

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘‘read more’ links in posts’ is closed to new replies.