Call custom field values in array of custom post type posts
-
Hi
I am having an issue with calling the custom field values from each custom post type.
I have created a custom post type “rankings ads”. In each post made within the custom post type has a custom field that needs to be entered. It is the url for the advertiser.At the moment my array to call the images from the various custom posts is working but I am not able to call the custom field values for each of the custom posts.
Unfortunately I cannot supply a url because the site is hidden behind a under construction page.
Below is the code function calling the array :<br /> //u19 IPT ranking tournament ads top function rank_u19_ad_top() {</p> // Call Sponsors of WPYS // add call for query $args = array('orderby' => 'date', 'order' => 'ASC', 'posts_per_page' => 10, 'tax_query' => array( array( 'taxonomy' => 'rankings', 'field' => 'slug', 'terms' => 'rank-u19-ipt', ) ) ); $query = new WP_Query( $args ); // The Loop $output = ''; while ( $query->have_posts() ) : $query->the_post(); $output.='<div class="add-top">'; $output.='<a href="'; $output.= $ad_url = get_post_meta($post->ID, 'ad-url', true); $output.='" rel="nofollow">'; $output.= get_the_post_thumbnail(); $output.=''; $output.='</div>'; endwhile; echo $output; // Reset Post Data wp_reset_postdata(); }
The bit that is not calling the custom field data for each post is :
$output.= $ad_url = get_post_meta($post->ID, 'ad-url', true);
The function is then displayed on another post.
Could someone please point me in the correct direction, I have not been able to find a solution in google.
Many thanks
This is urgent ??
- The topic ‘Call custom field values in array of custom post type posts’ is closed to new replies.