Read more link isn't working with custom query

Trying to show the latest post with a featured tag. The query is working fine but it always shows all the content.. not

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?

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?

Share Improve this question edited Jun 26, 2014 at 2:07 markstewie asked Jun 26, 2014 at 1:56 markstewiemarkstewie 1731 gold badge1 silver badge6 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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'); ?>

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742217488a4403224.html

相关推荐

  • Read more link isn&#39;t working with custom query

    Trying to show the latest post with a featured tag. The query is working fine but it always shows all the content.. not

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信