Each post object has a public member $post_parent
. That is the post ID of the parent post. So this should work:
$thumbnail="";
if ( ( 'event_posts' == get_post_type()
|| is_page( 'events' )
|| is_page( 'restaurants' )
|| is_page( 'recreation' )
|| is_page( 'entertainment' )
)
&& ! empty ( $GLOBALS['post']->post_parent )
)
{
$thumbnail = get_the_post_thumbnail( $GLOBALS['post']->post_parent );
}
echo $thumbnail;
Related Posts:
- How do you add thumbnail support for custom post types?
- Post featured image column on admin post list page
- Custom Field in Featured image for A particular post
- media_handle_upload for local files?
- How to add/assign or change featured image in post programmatically?
- How do I use element instead of tags in WordPress post content having webP support?
- VT-resize image and display it [duplicate]
- Posts Page Featured Image [closed]
- Showing Thumbnail from Previous and Next Posts
- How do I programmatically add an image to a post?
- How to Replace the WordPress Featured Image with a Video?
- Delete Post From Front-End and attachment permanently
- Require a featured image to publish post
- Underscores.me retrieve next / previous post thumbnail in post_nav function
- How to Set Featured image In WordPress without Showing it into Post?
- How only display all post related to category
- How do I find which articles are missing a featured image in The WordPress database?
- How to access featured image?
- Modify WP_Post before processing
- Show featured image next to post-teasers in Genesis Framework?
- Admin Notices don’t display on the admin screen for certain post
- What is the standard featured image size?
- Errors when uploading images in WP 3.5
- Set size for attachments
- why are images not full size?
- Post body text occupying featured image space before it loads
- Get all images in post and comments like Twitter before post title
- Issue where WP Featured Image will not display
- How to check if single.php has already called the_post_thumbnail function
- Getting only the URL of the post thumbnail
- Remove Featured Image & All Media Uploaded to the Post
- Get Post’s first image using Short-code
- related author post thumbnail shows post thumbnail
- Admin – no Featured image choice in create new/page|post
- Post Image not displaying in category view
- preg_replace not removed “class”
- how to give multiple post thumbnails to a post
- Using wp-cli and delete everypost first image
- How to display post title inside thumbnail?
- Post Title to featured Image ALT
- Get featured image on hover of post title [closed]
- Remove Featured Image from posts in specific category?
- Only show featured image on exerpt and exclude images in post
- How to display Post title By ID and its Thumb Contents
- Delete media from the post but keep my featured image and post
- Featured image error after importing blog posts
- Mysql update menu_order problem
- Set featured image as hero image on each page
- Thumbnails and images in the blog post are not loading
- Blog featured images disappeared on my homepage
- post thumbnails error
- Display images of related posts
- Center crop the feature image
- Add another feature image box
- How to show category image if no featured image is set?
- Set featured image on creating new post
- Display post on main page with thumbnail
- How to get all posts in gallery post format template
- Thumbnail With Next/Prev Links Not Showing Next Post?
- How do I get thumbnails?
- Latest news mini images
- Insert link to my thumbnail images
- thumbnail image path and file path for gallery thumbnail images
- Wanting to apply different featured images for each post
- Specific Post Format Image Thumbnail
- Post thumbnail is not shown in wp-admin
- Post thumbnail height problem
- Displaying warning if no featured image has been set – Post Editor
- How enter custom post meta or custom field on box post list archive page?
- $attachment->post_title not displaying title
- Import alt text in set_post_thumbnail
- website images getting corrupt automatically
- How to check if post meta key exists or not in wordpress database
- Portable Post Links
- Related Posts by Multiple Tags?
- WP REST API, query total posts in a category
- 404 error after publishing a post
- How to remove_filter that filters iframes in posts? [duplicate]
- Reset/Reorder posts ID in the MySQL wp_posts table
- Select a specific post to display in a news box
- Having trouble with the_post_thumbnail to display thumbnail with custom size
- How to exclude visited posts from loop
- get_posts not pulling the correct number of posts
- If custom field is empty, use one from a previous post
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- Why my meta boxes won’t show in front post page?
- Authors’ Links on Homepage Not Going to Author Post Pages
- Display Current Posts Category (with the most posts)?
- How can I add random alphabets in wordpress permalink posts structure
- Filter posts by month (dropdown)
- Redirect old Posts URL to new URL
- Display Custom Post Category Count & WordPress Category Count Using Shortcode
- How can I alternate styling of images in a post? [closed]
- How can I use the “Your latest posts” as a template?
- Query to get data of a post, if in category?
- Order posts by custom field
- Extra Theme – Fit image inside of Featured Post Slider
- How can I show the positive and negative comments for a same post separately?
- Moving featured image to top of new post editor screen
- Display posts with id equal to relationship value