Single Image from Field Group Not Displaying in Post

Support MB Builder Single Image from Field Group Not Displaying in PostResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #45774
    Anna LuszcakAnna Luszcak
    Participant

    I have a field group set up within Meta Box that includes a Single Image type that I am looking to display in my Custom Post Type Post using shortcode on WordPress. Right now, everything displays as expected, except for the image. Below is the section of PHP I am using. I've also included a few reference images for context.

    <div>
    
    if ($query->have_posts()) {
            while ($query->have_posts()) {
                $query->the_post();
                $url = get_post_meta(get_the_ID(), 'url', true);
                $description = get_post_meta(get_the_ID(), 'description', true);
                $lgbtq = get_post_meta(get_the_ID(), 'lgbtq', true);
                $woman_owned = get_post_meta(get_the_ID(), 'woman_owned', true);
                $minority_owned = get_post_meta(get_the_ID(), 'minority_owned', true);
                $size_inclusive = get_post_meta(get_the_ID(), 'size_inclusive', true);
                
                $output .= '<div class="designer-item">';
                $output .= '<a href="' . esc_url($url) . '">';
                $output .= get_the_post_thumbnail(get_the_ID(), 'medium');
                $output .= '<h3>' . get_the_title() . '</h3>';
                $output .= '</a>';
                $output .= '<p>' . esc_html($description) . '</p>';
                $output .= '<ul>';
                if ($lgbtq) $output .= '<li>LGBTQ+ owned</li>';
                if ($woman_owned) $output .= '<li>Woman-owned</li>';
                if ($minority_owned) $output .= '<li>Minority-owned</li>';
                if ($size_inclusive) $output .= '<li>Size-inclusive</li>';
                $output .= '</ul>';
                $output .= '</div>';
            }
            wp_reset_postdata();
        } else {
            $output .= '<p>No designers found.</p>';
        }
    
        $output .= '</div>';
        return $output;
    
    </div>
    #45792
    PeterPeter
    Moderator

    Hello Anna,

    What is the field ID of the single image field on your site? You can follow the documentation to output the single image field
    https://docs.metabox.io/fields/single-image/#template-usage

    #45803
    Anna LuszcakAnna Luszcak
    Participant

    I was able to resolve the issue on my own. When filling out the 'Post', there were three points to upload an image. Within the post, as a featured image, and in the form using my custom fields. While the image I uploaded to my customer field group in meta box worked, I was able to get my code to pull the featured image from the post.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.