I am looking for a wordpress plugin that allows my users to customize which posts are appearing on the home page. The users should have a settings page where they can select which categories and tags they´d like to see posts from.
Do you know if anything like that has been developed? Free or premium.
Not sure there’s any particular plugins for this, but it’s certainly possible with a few functions.
Easier than providing a settings page that’s seperate from the profile page, i’d actually suggest adding a couple of new fields to the user’s profile page, you can call the section home preferences or whatever you like.
Example follows…
Step 1 – Add custom fields to the user profile page
Here i took the same approach as Mike did when answering:
How to add custom form fields to the user profile page, firing on two actions to account for user profile saves and admin user edits.
Information on the term and category checklists can be found in the source(no docs yet).
http://core.trac.wordpress.org/browser/tags/3.0.2/wp-admin/includes/template.php#L217
Step 2 – Handle saving data on profile/user update
Again, two actions, depending on whether it’s a user saving profile changes or another user making changes to another user’s profile.
NOTE: It wouldn’t hurt to add further sanitization to the above.
Step 3 – Adjust the CSS
Indent children terms, float the main list items, so busy taxonomies don’t consume so much height.
NOTE: 30% width on the list items basically gives you the appearance of 3 columns of terms, you’re welcome to adjust the CSS to suit.
This could also just as easily be turned into an enqueue, which will provide some level of caching, inline CSS is quicker to test is all… 😉
Step 4 – Filter home query based on user prefs
Add a filter onto home queries based on user configured settings for tags and categories.
NOTE: You don’t have to use a
pre_get_posts
filter, you could useparse_query
or pass values into aWP_Query
object, i personally just find the chosen hook easy to use(and it’s what i’m use to using).UPDATE: Move the home prefs elements to the top of the profile page.
NOTE: There’s a slight HTML update to the
home_prefs_profile_fields
function also required, i’ve updated the function as appropriate in Step 1.RE: Checkboxes showing disabled from subscribers(see comments).
The reason this occurs is due to a capability check in the term checklist functions, these functions are typically used on post creation type screens, so expect the user to have the capability to assign terms to a post(or type), this obviously doesn’t apply to this particular case so we can safely remove the disabled attribute from them(jQuery above has been ammended with the appropriate change).
Hope that helps… 🙂
Have you looked at Justin Tadlock’s Query Posts plugin?
This code is untested, but put it in your function.php file ans see what happends.
In theory this should happen:
In your template, all you have to do is get the values from the meta tags by using this:
Then use this in you
query_post
.This is the plugin / code: