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 6666483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:50:00+00:00 2026-05-26T02:50:00+00:00

I am using wp_query in a category archive so that I can use the

  • 0

I am using wp_query in a category archive so that I can use the meta_query to ignore posts with certain meta values.

The problem is that since I am using wp_query, it seems to ignore the category that is currently being viewed and displays all the categories.

Is there a way to retrieve the category (perhaps as defined by the url) that the user is viewing and insert it into the wp_query argument array?

I’ve seen this suggested solution on stack overflow, but there must be a simpler way to do it since when no the default loop is used, wordpress automatically displays the correct category.

The code currently:

$query = array(
'meta_query' => array(
        array(
            'key' => 'Display',
            'value' => 'Yes',
        )
    ),
    'paged'=> $paged
);

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$pageposts = new WP_Query($query);

if ($pageposts):
while ( $pageposts->have_posts() ) : $pageposts->the_post();
  • 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-05-26T02:50:00+00:00Added an answer on May 26, 2026 at 2:50 am

    Well, this is the best solution I could come up with on my own (using single_cat_title to set the variable):

    $currentCategory = single_cat_title("", false);
    
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $query = array(
        'category_name' => $currentCategory,
    
        'paged'=> $paged,
        'posts_per_page' => '15'
    );
    $pageposts = new WP_Query($query);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm using WP_QUERY to get posts. the problem is that i want to sort
So I'm making a plugin that gets a set of posts (using wp_query), and
I'm using WP Alchemy to create a meta box in a post that allows
I'm using a WP_Query to query my custom post type posts. This custom post
I'm trying to link posts in wordpress. Let me elaborate. In wordpress, you can
I'm trying to setup a loop in Wordpress that will show all posts from
I'm new to MySQL and I'm having problem with a query using PHP. See
I've got a page that has a category list at the top, and should
First time using wordpress query so not sure how to handle this problem. I
Im trying to output or create json using wordpress posts data coupled with meta_key

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.