Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Let's say we started a custom loop:

<?php $custom_posts = new WP_Query(); ?>
<?php $custom_posts->query('post_type=post&category=Uncategorized&orderby=epo_custom'); ?>
<?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
(...)

I want to enable users to change for instance, the category part. In other words, something like this:

<?php $custom_posts->query('post_type=post&category=$user_selected_category&orderby=epo_custom'); ?>

So that value will be saved and the user will see only posts of that category each time he/she logs in.

Any suggestions to accomplish that?

EDIT:

I'll be getting the user preference at the time of his registration? Example: Lets say the user registers, and select his/her preferred category as 'business'.

share|improve this question
    
Will you be getting the user preference at the time of his registration? Example: Lets say I register, and select my preferred category as 'horror'. Get it? –  Rutwick Gangurde Dec 19 '11 at 8:01
    
@Rutwick Gangurde Edited the question thanks for asking. –  janoChen Dec 19 '11 at 8:10

1 Answer 1

User meta is the way to go friend! When you register the user via whatever you're using, save this preference as user meta for this user. Then when you render the template, get the current user id, and get this user meta before the loop and use it in the loop.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.