{"id":9517,"date":"2010-04-21T12:57:05","date_gmt":"2010-04-21T10:57:05","guid":{"rendered":"https:\/\/nl.wordpress.org\/support\/topic\/please-help-me-query-posts\/"},"modified":"2016-08-04T23:19:11","modified_gmt":"2016-08-04T23:19:11","slug":"please-help-me-query-posts","status":"closed","type":"topic","link":"https:\/\/nl.wordpress.org\/support\/topic\/please-help-me-query-posts\/","title":{"rendered":"PLEASE HELP ME: query posts???"},"content":{"rendered":"<p>Problem:<\/p>\n<p>How to create several div&#8217;s with different post categories?<\/p>\n<p>I tried a lot, didn&#8217;t get more than this. I can create several loops, but the second one doesn&#8217;t dissapear when going to the page of the post. I hope you understand and can help me. \ud83d\ude42 PLEASE!<\/p>\n<p>Sample: www.ukkepurk.nl\/blog<\/p>\n<pre><code>&lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;\n &lt;?php if ( in_category(&#039;3&#039;) ) { ?&gt;\n           &lt;div class=&quot;post-cat-three&quot;&gt;\n &lt;?php } else { ?&gt;\n           &lt;div class=&quot;post&quot;&gt;\n &lt;?php } ?&gt;\n &lt;h2&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to &lt;?php the_title_attribute(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;&lt;\/h2&gt;\n\n &lt;small&gt;&lt;?php the_time(&#039;F jS, Y&#039;) ?&gt; by &lt;?php the_author_posts_link() ?&gt;&lt;\/small&gt;\n\n &lt;div class=&quot;entry&quot;&gt;\n   &lt;?php the_content(); ?&gt;\n &lt;\/div&gt;\n\n &lt;p class=&quot;postmetadata&quot;&gt;Posted in &lt;?php the_category(&#039;, &#039;); ?&gt;&lt;\/p&gt;\n &lt;\/div&gt;\n &lt;?php endwhile; else: ?&gt;\n\n&lt;p&gt;Sorry, no posts matched your criteria.&lt;\/p&gt;\n &lt;?php endif; ?&gt;\n\n&lt;?php $myquery = new WP_Query(&#039;category_name=last&#039;); ?&gt;\n\n&lt;?php while ($myquery-&gt;have_posts()) : $myquery-&gt;the_post(); ?&gt;\n &lt;!-- Display the Post&#039;s Content in a div box. --&gt;\n &lt;div class=&quot;entry&quot;&gt;\n   &lt;?php the_content(); ?&gt;\n &lt;\/div&gt;\n\n&lt;?php endwhile;?&gt;\n\n&lt;?php wp_reset_query(); ?&gt;<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-9517","topic","type-topic","status-closed","hentry","topic-tag-query_posts"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/nl.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nl.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/nl.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/nl.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9517\/revisions"}],"wp:attachment":[{"href":"https:\/\/nl.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=9517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}