0

We are using the "Official AMP plugin" by AMP Project Contributors.

Our posts tend to have an image inserted at the top. Sometimes this is creating a duplication with the Featured Image.

How do I remove or deactivate the Featured Image portion of the AMP posts?

In the /plugins/amp/templates/single.php file, there is this line:

<?php $this->load_parts( [ 'featured-image' ] ); ?>

I would just remove this and save the single.php file, but with plugin updates, the custom changes are going to be wiped out.

So, I can edit the functions.php file of our current theme, to "add_action", for example. Thanks.

0

Try this code:

add_filter( 'amp_post_template_data', 'xyz_amp_remove_featured_image' );

function xyz_amp_remove_featured_image( $data ) {
    $data['featured_image'] = false;
    return $data;
}

More info about the amp hooks here https://amp-wp.org/documentation/how-the-plugin-works/classic-templates/

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.