Clicky

Loop

This article is for AMP Theme Framework users.

About this Component

Loop Component is responsible to render the data on home, archive, search pages.

How to use:

Following are the steps to use this component.

step 1:

To initiate the support for this component in your theme just add the following code to the functions.php of the theme files.

This was the back-end part where we’ve just initiated, now to make it appear in the front-end follow the next step.

step 2:

To add the Loop in home, archive, search pages we need to call it where we want to display it.
example: add the following code in index.php, archive.php,search.php of the theme files.

with this, you’ll be able to set loop on your theme.

step 3:

Now create loop.php to get loop contents on pages. In this page you can show the posts list details with pagination. follow these steps to add the required content in loop.php

step 3-I:

To start loop

To end loop

step 3-II:

Inside the loop, you can show different contents of the loop according to your needs like:
Show image of post

Show title of post

Show excerpt(Short description) of post

Show Categories of post

Show posted date of post

Show permalinks in the loop of post

If you want the permalinks in the loop for adding read more text etc then with the help of our amp_loop_the_permalink function you can add it easily like:

By using this function you will display the permalink for the loop


By using this function you will retrieve the full permalink for the loop. This function only gets the permalink from loop but it will not display you need to add echo for displaying. 

 

Brief structure of loop.php

Step 4

To Start the pagination( which will add next page and previous page links )

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 May 15, 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