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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:47:03+00:00 2026-06-13T00:47:03+00:00

This is fixed thanks to Alex’s answer below. So this is a bit of

  • 0

This is fixed thanks to Alex’s answer below.

So this is a bit of a weird one. I am setting up so I have category’s with names “cat1, cat2, cat3” etc.

And say I had users called “cat1, cat2, cat3” so they matched the same as the category names.

I am then wanting to somehow only show the posts to the user that relates to their category, so basically if USER: “cat1” is logged in then they could only see the posts in category “cat1” as it matches their username.

I know you can do this to show posts only that the current user logged in has made but this wont work as the way the posts get put into the category complicated to explain.

<?php
// The Query
$args = array(
'post_status'=> '.....'
);
global $user_ID;
get_currentuserinfo();
if($user_ID) {
query_posts( $args,"author=$user_ID" );
}

?>

So if anyone has any insight into only showing posts to a user that matches a category with the same name as the user logged in hopefully they will be kind enough to help out.

  • 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-13T00:47:04+00:00Added an answer on June 13, 2026 at 12:47 am

    It seems like you’ve started a round-about way of getting this accomplished. Since you have categories already set up with the username, you should just be able to place that in your query

    //Get User -> ID -> Cat
    global $current_user;
    get_currentuserinfo();
    $args = array(
        category_name => $current_user->ID
    );  //or use $current_user->display_name if that's how they are set up.
    
    // The Query
    $the_query = new WP_Query( $args );
    
    // The Loop
    while ( $the_query->have_posts() ) : $the_query->the_post();
        //Display your loop how you want
    endwhile;
    
    // Reset Post Data
    wp_reset_postdata();
    

    EDIT:

    did you do var_dump($current_user->ID) to see if it matches the category name? That variable from the object might only contain an ID (like “1” or “178” etc). If that was the case, you’d need something like

    $the_cat_name = 'category' . $current_user->ID;
    //Append your 'naming structure' to the front of the user ID
    

    Then just replace the array with

    $args = array( 
        category_name => $current_user->ID
    );
    

    Alternatively, look at the Current User Functions (here). You may be able to use

    $current_user->user_login
    

    instead. You could also just try var_dump($current_user) (after calling global $current_user; get_currentuserinfo();) and see what variable contains the string you need

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

Sidebar

Related Questions

Thanks for the response, @ManselUK Fixed this part with finding values(below) But , when
I have a foreach method like this one: public void Initialize(ClassB fixed) { foreach
I have a one-column webpage. Within this fixed-width column I want to have 3
I have this fixed-width file with the widths being 34, 2, 3, 2, 1,
I have a problem with IE. I have a fixed div like this: #fixed
I'm currently working on wholesale online t-shirt shop. I have done this for fixed
This is probably a dum error that can be fixed in seconds but have
Edit: My problem is fixed thanks to @Grumpy - still, if you have general
I was wondering how they fixed this kind of effect: On scroll to <div
This problem is easy fixed clientside. But for performance I want to do it

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.