Clicky

  1. Home
  2. Developer Docs
  3. Extending
  4. Making changes to featured-image file [Update Proof]

Making changes to featured-image file [Update Proof]

In order to making changes to featured-images file and retaining changes even on Plugin update for all Designs

You could do as follows here

Step 1: Create a Custom Plugin with the boilerplate code as follows

Step 2: Now the code that does your magic is in this section, But before that create a file in the same folder as our main Custom plugin file called ‘featured-image.php‘ with you custom code for featured Images on all designs

This should be your folder structure

Featured Image PHP

Your code for featured-image.php file along with your custom code

Now the code that actually is doing the magic goes into index.php as below

These changes will stay even if you update the plugin

Entire Code as a Plugin available here: download zip file from here and put it in /wp-content/plugin folder along with your modifications in featured-image.php

Step 1: Create a folder with the name “ampforwp” in your theme which you are currently using.

e.g: if you are using Twenty Seventeen theme then you have to create “ampforwp” folder in the twenty seventeen theme folder.

The directory will look like

ex: wp-content/themes/twentyseventeen/ampforwp

Step 2: Add the “single.php” file of the Swift theme to override the featured image.

The directory will look like

ex: wp-content/plugins/accelerated-mobile-pages/templates/design-manager/swift/single.php

In “single.php” file you need to remove the below function name – amp_featured_image() and replace it with your custom function name like in below the screenshot.

Step 3: In the functions.php file of the theme directory, you need to create your custom function for overriding featured image

Step 4: You needs to call that function in single.php of the swift theme like the below screenshot.

Now your featured image is successfully overridden.

That’s it for this tutorial!

We hope it helped you. If you have any feedback or questions, then please share them in the comments section below.

Ask your Questions Directly!
If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!
Updated on July 3, 2019

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support

Leave a Comment