Single Image from Field Group Not Displaying in Post
Support › MB Builder › Single Image from Field Group Not Displaying in PostResolved
- This topic has 2 replies, 2 voices, and was last updated 1 year, 3 months ago by
Anna Luszcak.
-
AuthorPosts
-
June 30, 2024 at 6:38 AM #45774
Anna Luszcak
ParticipantI 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>July 1, 2024 at 8:47 PM #45792Peter
ModeratorHello 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-usageJuly 2, 2024 at 4:04 AM #45803Anna Luszcak
ParticipantI 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.
-
AuthorPosts
- You must be logged in to reply to this topic.