You can get information on the currently logged in user using the get_currentuserinfo() function.
For example:
<?php
global $current_user;
get_currentuserinfo();
$username = $current_user->user_login;
$user_id = $current_user->ID;
?>
You can then use $username or $user_id in your custom loop.
<?php
// assign the variable as current category
$category = $user_id;
// concatenate the query
$args="cat=" . $category;
// run the query
query_posts( $args );
if ( have_posts() ) : while ( have_posts() ) : the_post();
// do something here
endwhile;
endif;
wp_reset_query();
?>
Related Posts:
- Build a content and excerpt grid loop with paging and options for # of posts
- Getting movie and serial on actor page
- how to display active, upcoming and past event with featured listing with pagination
- Display 4 chronological posts starting with a random post
- Insert all post IDs in new database table
- How to list posts from a plugin taxonomy?
- Pagination broken on is_front_page()
- change the default order of posts only for specific categories
- search.php to search only the post title
- Displaying POST content with HTML tags and all
- Create a hierarchical loop at predefined markup requirements
- How to modify this function to exclude also the post belonging to a specific category?
- /page/2/ redirect to 404
- Link on post title only if post have content
- Cleaning up WordPress to improve performance?
- List of all theme customizer control types?
- Modify previous and next text from pagination links
- Shortcode putting html such as
- Calling a method from functions.php on a click of a button
- How to redirect users to custom lostpassword page?
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- How to change featured content to a different tag in WordPress Twenty Fourteen?
- How do I create comment-reply-button using element not
- Two posts in same div – WP loop
- WordPress menu deletes when trying to add a hook
- Overriding a theme redux file in child theme
- Validate a users email address when using gmail to register
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- How to check If Oembed is empty or not
- Making Quote Plugin more efficient
- allow subscribers to see private posts without plug in
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Change the WP Video Shortcode Output
- How to pick the default selected value in wordpress dropdown?
- Using WP-API and SSE not authenticating user ID
- Validate functions before inserting then into functions.php
- How to retrieve current wordpress profile page URL?
- Search not showing all results
- How to Reference/Echo Variable from Another PHP Function
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- How can I make an object available through the entire site?
- WordPress admin-ajax.php
- What exactly do this function declared into functions.php file of a WP theme?
- How do I modify the custom footer text and get theme version number to show in wordpress admin?
- How to use html inside a functions.php code?
- Nested “do” and “add” Actions is possible?
- Display Data in Table from External Database in WP using Shortcodes
- How to check if a Customizer setting is set?
- linking stylesheets and scripts with functions.php
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Remove item in Checkout
- How to get current post category details inside “loop”?
- Only load certain artists on this page
- Create special button on WP Tiny MCE Posts Editor for Shortcodes
- Get the alt text of the image in a array
- Make table disappear when fields are left blank?
- How to Redirect Buddypress Directories To Login Page For Non Logged in Users
- Woocommerce order status payment
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Unzip file in functions.php, and add it to cron
- Add Block Before Entry Title Using PHP
- get value from get_post_meta then reuse it in another get_post_meta
- How to assign page id with array in page_scheduled_event
- Display logged in user name and lastname on page
- How to Add a cutsom slug to my custom author role
- Dynamically populate parameter in Gravity Forms using PHP
- Store ajax data in PHP variable
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- WordPress sorting posts by date and title using a dropdown
- How to output the taxonomies that are assigned to each custom post?
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- How can i create a function tag in my plugin
- How to escape echo for input tag?
- Including user data in “new user notification email”
- Display current user metadata on WordPress page
- Reload page with a different shortcode when a user selects from a dropdown
- Refresh page after login with litespeed cache
- Return newly created category by code
- Woocommerce Add custom “Add to cart button” in single page with tags
- Hook into all password resets in WordPress and get password before hashing?
- remove_action() not working in page template – Genesis
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- Dropdown menu on custom menu
- What is wrong in this code?
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- WordPress get_post_meta issue
- Woocommerce Price Text
- Modify php code to pass a page id as a parameter in order to create a breadcrumb
- Show custom default avatar instead of gravatar
- WordPress 2014 Theme – Featured Content with multiple tags?
- Does wp_query and query_posts affect website performance? [duplicate]
- ajax form function error
- Display custom meta box in my template file
- How to display the date under the post title?
- Simple Probléme in wordpress
- Contact form with dynamic dropdown and filter
- Critical Error customiser
- Automatically change insurance quantity based on cart total [closed]
- How to pass value to add_filter wpcf7_form_tag from another function?
- hiddenQuestions.find is not a function