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 badges2 Answers
Reset to default 0Finally 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
评论列表(0条)