0

Trying to show the latest post with a featured tag. The query is working fine but it always shows all the content.. not the content before the more link which is all I want.

Here is my code.

$query = new WP_Query('numberposts=1&orderby=date&tag=featured');

// The loop!
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>

<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>

<div class="post-meta-bar">
    <div class="date-meta">By <?php the_author(); ?> on <?php the_time('j F Y') ?></div>
    <div class="comment-meta"><a href="<?php the_permalink() ?>#comments" rel="bookmark" title="Link to <?php the_title_attribute(); ?>"><?php comments_number( 'Remove' ); ?></a></div>
</div>

<div class="entry">
    <?php the_content('Read More'); ?>
</div>


<?php endwhile; else: ?>

<p>Sorry, no posts are featured.</p>

<?php endif; ?>

In the editor I definitely have the <!--more--> link but it always shows ALL the content.

What am I doing wrong?

2 Answers 2

0

Finally found the answer for anyone else out there having the same problem.

Turns out for custom queries like mine using WP_Query more link functionality is OFF by default. To turn it on... this worked for me.

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

In the editor put Read More link. See in the screen shot.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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