2

I'd like to pull in profile info (name, web address, etc. + some custom-made fields) for specific users onto some of my category pages.

I realize I can pull in profile info using "current author," but this won't help in this case because the user won't be associated with the category page as an author.

For example, I'd like to be able to do the following.

On the Category A page I'd like to put User-John's profile information (but User-John isn't an author for any of the posts in Category A).

On the Category B page I'd like to put User-Bob's profile information (but User-Bob isn't an author for any of the posts in Category B).

But I will need to do this for hundreds or thousands, so I need a at least a somewhat automated way. I thought of using the Category Description box, but it doesn't seem to accept PHP (I've gotten it to accept HTML and even shortcodes).

Any ideas? ... Thanks in advance.

1
  • Could you explain more abotu why you would want to do this? It's not clear how you're planning to 'associate' these people with the categories ( how does it know to show John and not Marys profile data? ). If you can explain what you're trying to do then maybe we can offer alternatives that give the same result, or provide an automated solution
    – Tom J Nowell
    Apr 14, 2012 at 21:04

2 Answers 2

2

Add a metabox to the category edit screen with a user dropdown. Save the user ID as meta data.

In your category template use the meta user ID as argument for get_user_by():

// First find the ID, put it into $user_id then:
$author = get_user_by( 'id', $user_id );

See this post for an example how to get and use the author data.

1
  • Toscho - I was never notified of this reply, so I didn't realize you had left it. Thanks.
    – user15196
    May 16, 2012 at 17:48
0

You can get logged in user's profile using this global variable :

global $current_user;

You need to write code into category templates(category.php & archive.php)

Your Answer

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

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