This article is for AMP Theme Framework users.
Related Post Component is for displaying the related posts for the single in your AMP theme.
Following are the steps to use this component.
Step 1:
To initiate the support for the component in your theme just add the following code to the “functions.php” of the AMP Theme Framework directory.
// Related Posts
add_amp_theme_support('AMP-related-posts');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 Related Post we need to call it.
example: add the following code in “single.php” of the AMP Theme Framework directory.
<?php amp_related_posts(); ?>
with this, you’re successfully able to set Related Post on your theme.
But By default, it will show Image and Excerpt in Related Posts. If you don’t want image or excerpt in Related Posts then you can hide them using the Arguments.
Example: Add the following code to show Related Posts without Image and Excerpt.
$args = array('show_image'=>false, 'show_excerpt'=>false);
amp_related_posts($args);You can also call separate parts of Related Posts inside the Query.
// Query $my_query = related_post_loop_query(); // Title ampforwp_related_post(); // Image ampforwp_get_relatedpost_image(); // Excerpt and Author ampforwp_get_relatedpost_content();
But Wait, There’s more!
You can even crop the image according to your need.
ampforwp_get_relatedpost_image('full',array(
'image_crop'=>'true',
'image_crop_width'=>220,
'image_crop_height'=>134)
);That’s all!
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.
If you want to add an AWeber form in AMP then first you need to…
Webpushr is the fastest growing web push notifications platform that marketers love & developers rely…
Follow these steps to add Adobe Analytics in AMP Step 1: Go to WordPress Admin Area -> AMP…
Core Web Vitals are the subset of Web Vitals that apply to all web pages,…
The following reasons can be shown for non-indexing. Server error (5xx) Your server returned a 500-level…
We have added the Google Analytics 4 ( GA 4 ) integration in AMPforWP v1.0.80.…