I’m using Advanced Custom Fields plugin and microkid Related Posts.
I would like to display my custom fields inside Related post
This is what I got so far?
<?php //related artworks
$related = MRP_get_related_posts( $post->ID, true, false, 'quote_list' );
//for testing related array
//print_r ($related);
if(!empty($related)) {
foreach($related as $key => $value) {
$related = get_post($value);
$related_id=$related->ID;
$related_content=$related->post_excerpt;
$related_url=$related->get_permalink;
echo "<div><h4>".get_the_title($related_id)."</h4></div>";
//echo get_the_post_thumbnail($related_id);
echo "".$related_content."<br/><br/>";
echo "<a href=".get_permalink($related_id).">read more</a>";
//for testing related array
//print_r ($related);
}
}?>
But how I would pull out my advanced custom field?
Many thanks,
According to advenced custom fields you get the value with
get_field
http://www.advancedcustomfields.com/docs/functions/get_field/Just change “text_field” to your field-key.
Use the function get_post_meta() to get data to a custom field. Include this function in your loop and set the right parameters. The first parameter is the id of the post ($related_id) , the second is the key, the meta tags key/name, and the third parameter set to true, if you get a single parameters.
To get all meta data use get_post_custom($related_id).
For identifier the data and key can you use the plugin Debug Objects, but currently only the git version.https://github.com/bueltge/Debug-Objects