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.

Maybe I'm not doing things the proper way, but it seems to be working very well. Also, this question title is so confusing. I don't know how to ask the question. Perhaps someone can help edit? Thanks.

Question:

I have a custom post type: "employee"

Every "employee" CPT has a CPT Post with: "Firstname Lastname" + bio + image + metadata.

Example: John Doe (id=1234)

I have a single-employee.php template that outputs the single employee.

Everything works great.

Here's the hard part: the way this is setup, I HAVE TO separate employees from authors. So that's why I created a CPT. However, many employees are also registered blog authors. So they actually have blog posts that do exist.

*How can I loop through the employee CPT and output a UL of all blog posts by a single employee? *

Thank you

share|improve this question
3  
What have you tried so far? –  Wyck Mar 13 at 23:24
1  
It is not 100% clear what you've done but it sounds to me like you've set this up wrong. It sounds like you have a basic architecture problem, like you need a custom role and user meta, and not a CPT. –  s_ha_dum Mar 13 at 23:56
    
@TaiSem Your project sounds interesting. Could you contact me to chat about that? –  kaiser Mar 16 at 3:32

1 Answer 1

There are some flaws in the architecture as you've described it, but it may well be too far along for you to change that. If it's not, it would make more sense to extend the built-in user feature and just add the additional fields you need for that user.

If it's too far along for that, my recommendation would be to loop through the blog posts on an item that matches a field on the CPT.

For example, you could query_posts using author_name (if the employee CPT name matches) or you could do a custom $wpdb->query and loop through the posts where the email address or name or something similar matches.

But if I had a choice, I would go back and start over with extending the built in user functionality instead of using a CPT for it.

share|improve this answer
    
Please, do not recommend query_posts(). It messes with the main query, is an internal function and should not be used by anything other than core. –  kaiser Mar 14 at 7:56
    
Thanks. Yes, it's far along. The client needed employees completely separated from authors (I initially had them as authors). I agree with you, I will most likely go back to where I started. It will only effect faceted search features I have built, but yes, this doesn't seem proper/scalable. –  Tai Sem Mar 14 at 16:12

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.