0

I Have Created Custom Fields for Custom Post Type. when I retrieve the Values in Theme template image value returning 22. How can I get the image URL.?

<?php
    $args = array(
    'posts_per_page'   => -1, 
    'post_type'        => 'projects', 
    'post_status'      => 'publish',
    );
    $projects = get_posts( $args );

    foreach ($projects as $project) { 
        echo $project->project_title; // Title Text
        echo $project->project_description; // Description Content
        echo $project->project_image; // 22

     } ?>

When i Print $project

WP_Post Object
(
    [ID] => 35
    [post_author] => 1
    [post_date] => 2017-04-07 05:50:29
    [post_date_gmt] => 2017-04-07 05:50:29
    [post_content] => Tekzenit
    [post_title] => Tekzenit
    [post_excerpt] => 
    [post_status] => publish
    [comment_status] => closed
    [ping_status] => closed
    [post_password] => 
    [post_name] => tekzenit
    [to_ping] => 
    [pinged] => 
    [post_modified] => 2017-04-07 06:12:54
    [post_modified_gmt] => 2017-04-07 06:12:54
    [post_content_filtered] => 
    [post_parent] => 0
    [guid] => http://10.180.82.8/fareed/?post_type=projects&p=35
    [menu_order] => 0
    [post_type] => projects
    [post_mime_type] => 
    [comment_count] => 0
    [filter] => raw
)
1

you could just say:

get_the_post_thumbnail('', 'full')

just from the id itself since this is a custom meta.

wp_get_attachment_image($project->project_image, 'full')
  • i placed this tag <?php echo "image".get_the_post_thumbnail($project->ID, 'full');?> its not returing anything. – Developer Apr 7 '17 at 7:20
  • try the 2nd version now. i updated. – rudtek Apr 7 '17 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.