0

I have a custom post type called "Blog", in my templates I looping over the blog type and doing the following,

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
            <section class="news">
                <h2 class="title"><?php echo strtolower(the_title()); ?></h2>
                <h4><?php userphoto_the_author_thumbnail();?> Posted By <?php the_author(); ?> - <?php the_date("l jS M Y"); ?></h4>
                <p class="tags">
                    <?php $tags = wp_get_post_tags($post->ID); ?>
                    <?php foreach ($tags as $tag) : ?>
                        <a href="<?php echo $tag->slug; ?>"> <?php echo $tag->name; ?> </a> |
                    <?php endforeach; ?>
                </p>
                    <?php the_content("Read More"); ?>
            </section>
        <?php endwhile; endif; ?>

My post consists of this content,

Hello World I am teaser  
<!--more-->  
Hello World I am a the content

I am expecting the output to looks like this,

Hello Word I am teaser
<a href="link_url">Read More</a>

However what I am getting is the following,

   Hello World I am teaser  

   Hello World I am a the content
1
  • I would look in your theme's function file to see if it is being stripped out for some reason.
    – Wyck
    Aug 12, 2011 at 16:42

2 Answers 2

2

Try adding the global $more variable before you call the_content(). e.g.:

<?php
global $more;
$more = 0;
the_content( 'Read More' );
?>

(This is how you enable the "Read More" tag for Pages.)

1

Try replacing what you have wit this:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <section class="news">
        <h2 class="title"><?php echo strtolower(the_title()); ?></h2>
        <h4><?php userphoto_the_author_thumbnail();?> Posted By <?php the_author(); ?> - <?php the_date("l jS M Y"); ?></h4>
        <p class="tags">
            <?php $tags = wp_get_post_tags($post->ID); ?>
            <?php foreach ($tags as $tag) : ?>
                <a href="<?php echo $tag->slug; ?>"> <?php echo $tag->name; ?> </a> |
            <?php endforeach; ?>
        </p>
      <?php the_excerpt(); ?>
    </section>
<?php endwhile; endif; ?>

Then add this to your functions.php in place of what is now there for the more tag (if any exists):

<?php
function all_excerpts_get_more_link($post_excerpt) {
  return '' . $post_excerpt . '' . '<span class="readmore"><a href="'. get_permalink($post->ID) . '">' . 'Read More' . '</span>';
}
add_filter('wp_trim_excerpt', 'all_excerpts_get_more_link');
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.