How to get the custom fields from 2 custom post types?
-
Hello,
Last night I was breaking my head for several hours regarding this, without any clue…
So any help is very much appreciated and would mean a breakthrough for me in using wordpress. This said…my data usage
I created a custom post type: ct_persons
I created a second post type: ct_lessonsct_persons contains relevant information on people (personID, name, image,…)
ct_lessons contains relevant information on lessons (lessonID, teacherID, lessonName, date, start,end,…)
to link them in a way: the value of personID (ct_persons) and teacherID (ct_lessons) correspond to each other.Now I created a page-lesson template to make a table of all lessons. However I am struggling to get my data added from ct_persons.
What I do
I can create this via the_loop() and custom fields on ct_lessons.
my table looks like this:
lessonNumber – date – start – end – teacherID – lessonNameWhat I still need
but need to get to the custom field of ct_persons (personName) as well
and eventually link hem to a page with information on that teacher
my table should look like this:
lessonNumber – date – start – end – personName(and link to teacherInfoPage) – lessonNamemy struggle
I already tried several things, including custom SQL queries, but do find it rock hard (being a novice). eg. I tried using JOIN and comparing values, but since I query 1 table (wp_postmeta), this doesn’t seem to work properly. Can anyone guide me in the right direction what should be the best approach for this case? Thank you in advance!ps: I am not posting any code, since this will only make it more confusing and I am not yet sure how to approach it… If anyone more experienced could guide me on this, it would help me a lot!
- The topic ‘How to get the custom fields from 2 custom post types?’ is closed to new replies.