In the process of theme creation, it is inevitable that sometimes it is necessary to adjust the number of output articles, so query_post needs to be used. , is_tag() and other WP internal functions are invalid.
Usually we use code like the following:
<? php query_posts( 'showposts=10' ); ?>
//We add an operation to let him display 10 posts at the beginning
<? php while (have_posts()) : the_post(); ?>
//It's you I will not write the content in detail about some output that is required.
<? php endwhile ;?>
After using query_post, it is often easy to make judgment mistakes. Since we know that it is caused by query_post, in order to avoid this phenomenon, we should add wp_reset_query(); after endwhile; to jump out of query. See the following code:
<? php query_posts( 'showposts=10' ); ?>
//We add an operation to let him display 10 posts at the beginning
<? php while (have_posts()) : the_post(); ?>
//It's you I will not write the content in detail about some output that is required.
<? php endwhile ;?>
<? php wp_reset_query(); ?>
Everything returned to its former tranquility.