How to retrieve text/data from custom type's custom/additional fields
-
Hi Folks,
Im hoping someone here can point me in the right direction to solving this problem as I’m at a dead-end with it. I created a custom type using the PODS Framework plugin and for this custom type I added some additional/custom fields. I then created a standard page and used a standard template for it but I cannot seem to find the right syntax to be able to use the text/data from the custom fields on my template page. ON this template page I created a query to retrieve the custom types as follows:
$args = array(‘post_type’=>array(‘products’));
$productsQueryResults = new WP_Query( $args );The above query works fine and its returning the correct data as I have dumped it using print_r( $productsQueryReslts );. I cannot see any of the custom fields mentioned in this dump as it seems to just be the normal post data. I am able to echo/output the title and content using the following code
the_title();
the_excerpt();However I do not know how to call the custom fields correctly, the only snippet of code I have come across in the codex is the snippet below however this fails to return anything.
echo get_post_meta($post->ID, ‘service_header’, true);
I have used the code below to retrieve a similar custom type and display it on my single-<custom type name>.php template file but the same code seems to be failing on the template page for some bizzare reason. Any and all assistance appreciated.
$args = array( ‘post_type’ => ‘services’, ‘posts_per_page’ => 10 );
$loop = new WP_Query( $args );while ( $loop->have_posts() ) : $loop->the_post();
echo get_post_meta($post->ID, ‘Title’, true);
the_title();
echo ‘<div class=”entry-content”>’;
the_content();
echo ‘</div>’;echo get_post_meta($post->ID, ‘the_title’, true);
echo get_post_meta($post->ID, ‘service_header’, true);
echo get_post_meta($post->ID, ‘service_intro’, true);
echo get_post_meta($post->ID, ‘service_copy’, true);
echo ‘Col1 Header’;
echo get_post_meta($post->ID, ‘service_point_column1_header’, true);
echo get_post_meta($post->ID, ‘service_point_column1_points’, true);endwhile;
- The topic ‘How to retrieve text/data from custom type's custom/additional fields’ is closed to new replies.