Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your problem is two-fold:</p> <p>1) <strong>It is imperitive you stop using query_posts</strong>. There are many well-documented reasons as to why using this function needs to end, but I think <a href="https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts">this is the best explanation</a>.</p> <p>2) You aren't resetting your query. More on that in a minute.</p> <p>Going back to number 1, the problem with query_posts is that it affects the global $wp_query object. This would be fine if your intention was to modify the main loop, but that's not what you're trying to do here. What you need to use is <a href="http://codex.wordpress.org/Class_Reference/WP_Query" rel="nofollow noreferrer">WP Query</a>. The syntax in creating a new Query Object is identical to query_posts, but the benefit is that you are no longer affecting the global instance of $wp_query.</p> <p>Resetting your query also ensures that no other sections of code utilizing a Wordpress Query are going to be affected by your Query Object.</p> <p>Try changing your code example to this:</p> <pre><code>&lt;?php $query = new WP_Query(array('category_name'=&gt;'left_sidebar','posts_per_page'=&gt;4,'orderby=menu_order')); if($query-&gt;have_posts()) : while($query-&gt;have_posts()) : $query-&gt;the_post(); ?&gt; &lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt; &lt;?php endwhile;endif; wp_reset_postdata(); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload