1. Home
  2. Developer Docs
  3. Extending
  4. Modify Homepage Posts Loop of AMP Version the Right Way

Modify Homepage Posts Loop of AMP Version the Right Way

This tutorial is a part of the developer’s documentation. It is recommended that you have some knowledge of coding before you proceed because we don’t want to break your live sites ūüėČ – If coding isn’t your thing then you should forward this tutorial to your developer.

What’s the Goal:

In this tutorial, we will look at the way in which we can modify the list of posts (technically known as Loop) appearing on the Home Page to whatever we want.

Before we even start let’s get the main concept straight, What exactly are are we trying to modify on Homepage of our website?

It is a set of posts that is output on Home Page

Now in order to modify the output, we need to follow the following steps:

    1. Go to Plugins folder located in your WordPress installation in
    2. Create a folder called “amp-home-output-modify” in the ¬†plugin’s folder
    3. In the folder¬†“amp-home-output-modify” create a file “index.php”
    4. write the following code to the file

    1. After this step just save the file and activate the plugin once, if everything’s¬†working fine proceed
    2. add the following code to index.php file
    3. now you can look at another example at line 15-22
    4. to run this example copy lines between 15-22 and replace with lines 31-35, save and run

and you are done, change the parameters accordingly in the code to what you want to display and simply activate the plugin.

Making it Update Proof:

We don’t have to touch the core plugin to make these changes, so we’re making an external lightweight plugin to make these changes. Actually, this is a standard and recommended way by WordPress.

You can download the final plugin file and put it in your plugins folder. This will make sure that everything is update proof.

Closing notes:

In today’s tutorial, we¬†learned how to modify the homepage loop and make changes to it. In the final code, we covered two use cases, ‘How to exclude specific categories from the homepage loop’ and ¬†‘How to show posts from other custom post types’.

Please let us know if this was helpful for you and please send other suggestions for the tutorials.

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 June 24, 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


  1. Doing this makes the pagination useless.
    Every page is showing the same exact posts :s

    1. Hey I√Īigo
      Can you please share your exact code? I will use that same on my local installation and see what the problem is and come up with a solution. So that I can help you fix it.


      1. Did you find solution to that problem?? I’m having that same problem and I did exactly what was told in the article.

  2. I have the same problem in pagination !
    how can I solve it ?

  3. Your Code and Images Doesn’t Shows up in AMP Version of Your Website.

    1. Hi Taranjeet Singh,

      We have checked the AMP website and it’s working properly will you please check now and let us know.

Leave a Comment