Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress - display certain categories on homepage
    text
    copied!<p>I have been trying to alter my current code, but it makes no sense to me (it doesn't do what I was told it does). All I want to do is only display posts with category 13 on my homepage and I want to be able to add multiple categories to a post. </p> <ul> <li>Post 1 (Category 13 and 1) = displayed on homepage </li> <li>Post 2 (Category 13 and 4 and 5) = displayed on homepage </li> <li>Post 3 (Category 6 and 1) = not visible on homepage</li> <li>Post 4 (Category 2) = not visible on homepage</li> </ul> <p>This is my current code to only show category 13 on my homepage, if another category is added to the post it won't be displayed at all.</p> <pre><code>&lt;?php get_header(); ?&gt; &lt;div id="primary"&gt; &lt;div id="content" role="main"&gt; &lt;?php if (is_home()) { query_posts("cat=-6,-4,-1,-11"); } ?&gt; &lt;?php if ( have_posts() ) : ?&gt; &lt;?php twentyeleven_content_nav( 'nav-above' ); ?&gt; &lt;?php /* Start the Loop */ ?&gt; &lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;?php get_template_part( 'content', get_post_format() ); ?&gt; &lt;?php endwhile; ?&gt; &lt;?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'cat' =&gt; 13, 'posts_per_page' =&gt; 5, 'paged' =&gt; $paged); query_posts($args); ?&gt; &lt;?php twentyeleven_content_nav( 'nav-below' ); ?&gt; &lt;?php else : ?&gt; &lt;article id="post-0" class="post no-results not-found"&gt; &lt;header class="entry-header"&gt; &lt;h1 class="entry-title"&gt;&lt;?php _e( 'Geen berichten beschikbaar', 'twentyeleven' ); ?&gt;&lt;/h1&gt; &lt;/header&gt;&lt;!-- .entry-header --&gt; &lt;div class="entry-content"&gt; &lt;p&gt;&lt;?php _e( 'Helaas, er zijn nog geen gearchiveerde berichten in deze categorie. ', 'twentyeleven' ); ?&gt;&lt;/p&gt; &lt;?php get_search_form(); ?&gt; &lt;/div&gt;&lt;!-- .entry-content --&gt; &lt;/article&gt;&lt;!-- #post-0 --&gt; &lt;?php endif; ?&gt; </code></pre>
 

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