lemoigneL
Support threads created in the last 30 days: 0
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
Child post fields are shown with types_child_fields but not with get_posts
Started by: lemoigneL
in: Toolset Professional Support
Problem: I have some custom code that uses types_child_posts to get a list of child posts. Then I am able to use the $post->fields['field-slug'] syntax to display custom post fields from the child post. However, if I use the native WordPress get_posts function to get the child posts, I am not able to use the same $post->fields['field-slug'] syntax to get information about a custom field. Solution: The native WordPress get_posts function does not return information about custom fields, so you must use get_post_meta to retrieve custom field information about each post returned by get_posts. $date = get_post_meta(get_the_ID(), 'wpcf-date', true); echo date('l jS \of F Y h:i:s A', $date); Relevant Documentation: |
2 | 5 | 7 years ago |