Dynamically set front page featured image from first image in latest post’s ACF gallery

My front page template is set to display the full content of the latest post using WP_Query and a custom page template. Now I want the home page featured image to dynamically change every time a new post is published. The goal is to show the first image from the latest post’s ACF gallery when sharing the home page on social media.

I am not great with PHP so Im not sure if I am even approaching this the right way. So far this code does nothing. Do I need to hook my function to something else? Where am I going wrong?

// Set front page featured image to first image in surf report cpt ACF gallery  function set_home_featured_image_from_ACF_gallery () {      global $  post;      // Get front page id     $  frontpage_id = get_option( 'page_on_front' );      // Get id of latest post     $  recent_posts = wp_get_recent_posts( array( 'numberposts' => '1' ) );      // Set $  post_id variable to latest post id     $  post_id = $  recent_posts[0]['ID'];       if ( is_front_page() ) {          /* Get the home page thumbnail (should i be getting the home page thumbnail here or the post thumbnail of the latest post?) */          $  has_thumbnail = get_the_post_thumbnail($  frontpage_id);              // Get the first image from the ACF gallery in the latest post             $  images = get_field('surf_report_gallery', $  post_id, false);             $  image_id = $  images[0];               if ( $  image_id ) {           // Set home page featured image to first ACF image            set_post_thumbnail( $  frontpage_id, $  image_id );         }            }    } add_action( 'save_post', 'set_home_featured_image_from_ACF_gallery' ); 

Also, every time I share the home page it wants to display an image that I have removed from the site completely. Even when I manually add a featured image in the page editor. Weird…

Want to link featured images to Amazon product page

Can anyone help me here –
I want to link the featured images on the product page directly to the amazon aff link for that product.

So when a visitor visits my site or product page and clicks on an image they go directly to the amazon aff link for that product..

I'm guessing I just need to <a href> the product image which I tried but didn't work – here is what I tried on the product.tpl file –

<div class="product-images-container col-smd-6 col-md-6">
<a…

Want to link featured images to Amazon product page

Classifieds Site For Apps – Paid Featured Ads Options and Adsense Revenue

Why are you selling this site?
I am need of money for Xmas so selling off some of my websites. I have a family to support and want to give my 6 year old son a good Xmas.

How is it monetized?
Adsense and Ad Sales.

Does this site come with any social media accounts?
Twitter Account: @AppFreeAds

How much time does this site take to run?
The site is completely automated.

What challenges are there with running this site?
There are no real challenges, only…

Classifieds Site For Apps – Paid Featured Ads Options and Adsense Revenue

Featured Snippets Not Picked By Google. Why?

We have added content in Tabular format in our website like Our Competitors are doing but these featured snippets are picked by Google but our Not. We are using react to develop our website? Is there any issue with our programming language our problem with our table placement.

Some Keywords Sample & Featured Snippets Picked By Google:
1. maldives honeymoon packages – https://www.thomascook.in/holidays/international-honeymoon-packages/maldives-honeymoon-destination enter image description here

  1. sri lanka tour packages – https://www.yatra.com/international-tour-packages/holidays-in-sri-lanka enter image description here

  2. mauritius honeymoon packages – https://www.thomascook.in/holidays/international-honeymoon-packages/mauritius-honeymoon-destination enter image description here

  3. goa tour package – https://www.makemytrip.com/holidays-india/goa-travel-packages.html enter image description here

Our URL For Same Keywords Targeting are mentioned below:

https://traveltriangle.com/honeymoon-packages/maldives
https://traveltriangle.com/tour-packages/sri-lanka
https://traveltriangle.com/honeymoon-packages/mauritius
https://traveltriangle.com/tour-packages/goa