• mikejeffs

    (@mikejeffs)


    I’ve got a set of pre existing posts in my database. But there is no <readmore> tags or excerpts included. Just post title and the post content.

    All the other posts in the blog use a readmore tag after the first paragraph and my templates for index and category are setup to show just this title and 1st para.

    Is there anything I can do to automatically make only the first X words of posts be displayed on these posts without <readmore> tags?

    Alternativly, if the 2 systems (readmore tags/1st x words) can’t co-exist, how can I go about changing things so all posts show the first 50 words?

    many thanks, i hope this was clear, I’m a bit confused as to whether this should be a coding issue or templating or if there is a option hidden away that I’m missing.

    thanks
    Mike

Viewing 3 replies - 1 through 3 (of 3 total)
  • o-juice

    (@o-juice)

    Well, you could amend the index.php file where the post’s content gets displayed from — <?php the_content(); ?> — to <?php the_excerpt(); ?> and put a <a href="<?php the_permalink() ?>">read more...</a> link at the end of it so that when a reader clicks on it they’ll get taken to the single.php template where you display the full post content (i.e. <?php the_content(); ?>

    Kafkaesqui

    (@kafkaesqui)

    I’d suggest a bit of scripting along these lines, which tests if the ‘more’ Quicktag is in the post content, and based on that decides whether to use the_content() tag, or the_content_rss() tag with the ‘cut’ parameter set to 50 .

    Replace the_content() tag in your templates (other than single.php (1.5)) with it:

    <?php if(preg_match('/<!--more-->/', $post->post_content)) : ?>
    <?php the_content(); ?>
    <?php else : ?>
    <?php the_content_rss('', TRUE, '', 50); ?>
    <a href="<?php the_permalink(); ?>">(more...)</a>
    <?php endif; ?>

    Thread Starter mikejeffs

    (@mikejeffs)

    Thanks for your help – worked a dream 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to auto add “read more” link?’ is closed to new replies.