First, you will have to add the categories to user profiles. This question has been addressed before. That will give you the possibility to retrieve an array $data with the category ID’ a user is interested in.
Now, you will need to turn that array into a list of posts. Depending on where you want to show it, this goes in index.php
or sidebar.php
or maybe even footer.php
. You could also make into a widget. At the location where you eventually need your html you write:
$data = get_the_author_meta( 'user_categories', $user->ID );
if (empty($data)) $data = array (1, 2, 3, 4); // default categories to show
Next you need to define a query which restricts the returned posts to those belonging to a specific category. It wil look something like this:
$query = new WP_Query( array( 'posts_per_page' => 3, 'cat' => $data ) );
Now $query
holds an array of max 3 posts in categories with the desired ID’s. You can use a foreach
loop to go through them in the usual way.