• How would one go about overriding the structure of amp_loop_template()? So, basically, what I’m trying to achieve is a new layout for amp_loop_template(). By default, amp_loop_template() loads up with the post image on the left and the title and other information on the right. Is there a way to override amp_loop_template() and have the full image load up. Once that is done, I can easily remove the float and give these sections custom css in style.php.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    you can do that with the AMP theme framework: https://ampforwp.com/amp-theme-framework/

    using Loop https://ampforwp.com/tutorials/article/loop/

    Does that work for you?

    Thread Starter vagu71

    (@vagu71)

    There is a file in loop.php (which is inside the folder amp-theme-framework-master) that has the following code:

    <?php while(amp_loop('start')): ?>
    <div class="loop-post">
        <?php amp_loop_image(); ?>
        <?php amp_loop_category(); ?>
        <?php amp_loop_title(); ?>
        <?php amp_loop_excerpt(); ?>
        <?php amp_loop_date(); ?>
    </div>
    <?php endwhile; amp_loop('end');  ?>
    <?php amp_pagination(); ?>

    It appears that this line of code amp_loop_image() is being used to fetch the loop image. Is there a way to edit the code for this function and have it load the full sized image and not the cropped one? And also keep the changes persistent on plugin update.

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    We have those parameters, you can just use them to get any size you want. We will write a documentation about this, but let me share an example over here:

    <?php
    $width 	= 350;
    $height = 190;
    $args = array("tag"=>'div',"tag_class"=>'image-container','image_size'=>'full','image_crop'=>'true','image_crop_width'=>$width,'image_crop_height'=>$height, 'responsive'=> true); ?>
    <div class="rp-img">
    <?php amp_loop_image($args); ?>
    </div>
    

    If you want the default sizes of WP, then you can use the “image_size”, or if you want the exact cropped image, then use can change the values in width and height.

    We will have a full documentation on that very soon.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘amp_loop_template() Override’ is closed to new replies.