Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8665655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:32:13+00:00 2026-06-12T17:32:13+00:00

I have been trying to alter my current code, but it makes no sense

  • 0

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.

  • Post 1 (Category 13 and 1) = displayed on homepage
  • Post 2 (Category 13 and 4 and 5) = displayed on homepage
  • Post 3 (Category 6 and 1) = not visible on homepage
  • Post 4 (Category 2) = not visible on homepage

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.

<?php get_header(); ?>

<div id="primary">
<div id="content" role="main">

<?php
    if (is_home()) {
        query_posts("cat=-6,-4,-1,-11");
    }
?>

<?php if ( have_posts() ) : ?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
    <?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>
        <?php get_template_part( 'content', get_post_format() ); ?>
    <?php endwhile; ?>

<?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
    'cat' => 13,
    'posts_per_page' => 5,
    'paged' => $paged);
    query_posts($args);
?>

<?php twentyeleven_content_nav( 'nav-below' ); ?>

<?php else : ?>
    <article id="post-0" class="post no-results not-found">
    <header class="entry-header">
    <h1 class="entry-title"><?php _e( 'Geen berichten beschikbaar', 'twentyeleven' ); ?></h1>
    </header><!-- .entry-header -->

    <div class="entry-content">
    <p><?php _e( 'Helaas, er zijn nog geen gearchiveerde berichten in deze categorie. ', 'twentyeleven' ); ?></p>
    <?php get_search_form(); ?>
    </div><!-- .entry-content -->
    </article><!-- #post-0 -->
<?php endif; ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:32:14+00:00Added an answer on June 12, 2026 at 5:32 pm

    You’re looking way too hard at this code. You don’t need to exclude anything, you just need to include cat 13, which will include everything that is in cat 13; even if it is in other categories as well. Just run a regular WP_Query() like so:

    <?php get_header(); ?>
    
    <div id="primary">
    <div id="content" role="main">
    
    <?php
        if (is_home()) {
            // The Query
            $the_query = new WP_Query("cat=13, paged=".get_query_var('paged'));
        }
    ?>
    
    <?php if ( have_posts() ) : ?>
    <?php twentyeleven_content_nav( 'nav-above' ); ?>
        <?php /* Start the Loop */ ?>
        <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <?php get_template_part( 'content', get_post_format() ); ?>
        <?php endwhile; ?>
    <?php twentyeleven_content_nav( 'nav-below' ); ?>
    
    <?php else : ?>
        <article id="post-0" class="post no-results not-found">
        <header class="entry-header">
        <h1 class="entry-title"><?php _e( 'Geen berichten beschikbaar', 'twentyeleven' ); ?></h1>
        </header><!-- .entry-header -->
    
        <div class="entry-content">
        <p><?php _e( 'Helaas, er zijn nog geen gearchiveerde berichten in deze categorie. ', 'twentyeleven' ); ?></p>
        <?php get_search_form(); ?>
        </div><!-- .entry-content -->
        </article><!-- #post-0 -->
    <?php endif; ?>
    

    (had to add a few charachters or I could not edit, sorry :P)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is my code and I have been trying to color the cells but
trying to display data only after variables have been set. $(document).ready(function () { function
I have been searching all night for an answer to this but can't seem
I have been trying to post using RestKit after I have successfully used it
Have been trying to encrypt an xml file to a string so that I
Have have been trying to make a validator for my xml files. I have
I have been trying to setup git for our web development team unsuccessfully. Some
I have been trying for almost a week now to create an SQLite database
I have been trying to generate report as per age differences of different months
I have been trying to create a ListView which I can sort using drag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.