get value of custom field of all post of a custom type
-
Hi,
I have a custom post typoe called ‘product’. I found the following snippet to get alle post with this tpye. I can echo all titles, but i am tio confused to get the get_post_meta of the post. how can i refer to $post->ID inside my loop
regards
// get all products $type = 'priduct'; $args= array( 'post_type' => $type, 'post_status' => 'publish', 'posts_per_page' => -1 ); $my_query = new WP_Query($args); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : echo the_title(); $imagepath = get_post_meta($post->ID, 'producticon', true); endwhile; } wp_reset_query();
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘get value of custom field of all post of a custom type’ is closed to new replies.