Problem: I have a post reference custom field and I would like to access the reference post's title and ID in PHP.
Solution:
Use get_post_meta to determine the reference post ID, then use get_the_title to determine the reference post title:
$contributor_id2 = get_post_meta( $post_id, "wpcf-post-contributor2", true); $contributor_id2_title = get_the_title( $contributor_id2 ); echo "Post ID: " . $contributor_id2 . ", Title: " . $contributor_id2_title;
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 3 replies, has 2 voices.
Last updated by 6 years, 6 months ago.
Assisted by: Christian Cox.