0

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'.

2
  • 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? Commented Dec 19, 2011 at 8:01
  • @Rutwick Gangurde Edited the question thanks for asking.
    – wyc
    Commented Dec 19, 2011 at 8:10

1 Answer 1

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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