I set up a meta field related_topics
that I use to associate lesson
topics
to a custom post type lesson
.
I read here
https://stackoverflow.com/questions/19640850/wordpress-how-to-return-meta-with-query-posts
that you can access meta fields directly from a post object in the manner $post->my_field
.
For a given lesson
there could be several related topics
. For a given lesson
that has multiple topics
, I noticed that $post->related_topics
only returns the first topic
instance, when in fact there are more than one. Is there some method to use, something like $post->related_topics->all()
? Maybe with this convention only one item is returned by default even if there is a collection?
thanks, Brian
$post->related_topics
is not a standard field on theWP_Post
object (the post object only contains the data from thewp_posts
table). Are you adding this?get_post_meta()
to get the data you're putting into it, so that's really what you should be asking about.