Support » Plugin: AMP » How can I modify footer.php (amp/templates) with my own plugin or child theme?

  • Resolved aniads

    (@aniads)


    Hello,
    How can I modify footer.php (amp/templates) with my own plugin or child theme?
    I need to add <amp-next-page> code and next-page-hide to the footer tag.
    How can I do it??? Is it possible with hook?

    I have tried to put this file in my plugin or childtheme folder and I have an error with $THIS.

    I am using Reader Mode with AMP Legacy.

    This is the original file:

    <?php
    /**
     * Footer template part.
     *
     * 🚫🚫🚫
     * DO NOT EDIT THIS FILE WHILE INSIDE THE PLUGIN! Changes You make will be lost when a new version
     * of the AMP plugin is released. You need to copy this file out of the plugin and put it into your
     * custom theme, for example. To learn about how to customize these Reader-mode AMP templates, please
     * see: https://amp-wp.org/documentation/how-the-plugin-works/classic-templates/
     * 🚫🚫🚫
     *
     * @package AMP
     */
    
    /**
     * Context.
     *
     * @var AMP_Post_Template $this
     */
    ?>
    <footer class="amp-wp-footer">
    	<div>
    		<h2><?php echo esc_html( wptexturize( $this->get( 'blog_name' ) ) ); ?></h2>
    		<a href="#top" class="back-to-top"><?php esc_html_e( 'Back to top', 'amp' ); ?></a>
    	</div>
    </footer>
    • This topic was modified 2 years, 8 months ago by aniads.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Milind More

    (@milindmore22)

    Hello @aniads

    Thank you for the support topic, You can override the amp legacy template by creating amp directory in your active theme and adding footer.php file to it

    wp-content/themes/your-active-theme/amp/footer.php

    More information is in our guide.

    Hope this helps!

    Thread Starter aniads

    (@aniads)

    Thank you, but I have tried this earlier. It didn’t work then.
    I had an error.
    But now it works. I don’t understand…
    Maybe this is because I’ve deleted this:

    /**
     * Footer template part.
     *
     * 🚫🚫🚫
     * DO NOT EDIT THIS FILE WHILE INSIDE THE PLUGIN! Changes You make will be lost when a new version
     * of the AMP plugin is released. You need to copy this file out of the plugin and put it into your
     * custom theme, for example. To learn about how to customize these Reader-mode AMP templates, please
     * see: https://amp-wp.org/documentation/how-the-plugin-works/classic-templates/
     * 🚫🚫🚫
     *
     * @package AMP
     */
    
    /**
     * Context.
     *
     * @var AMP_Post_Template $this
     */
    

    Is this code required?

    • This reply was modified 2 years, 8 months ago by aniads.
    • This reply was modified 2 years, 8 months ago by aniads.
    Plugin Support Milind More

    (@milindmore22)

    ok, please make sure that you have correct path just /amp/ and not /amp/template/,

    Also, please share the complete error message and theme (main site theme)

    Thread Starter aniads

    (@aniads)

    As I said above – now it works. I don’t know why…
    Maybe this is because my footer.php has now original code – commented code (earlier I’ve deleted this):
    Is this code required?

    /**
     * Footer template part.
     *
     * 🚫🚫🚫
     * DO NOT EDIT THIS FILE WHILE INSIDE THE PLUGIN! Changes You make will be lost when a new version
     * of the AMP plugin is released. You need to copy this file out of the plugin and put it into your
     * custom theme, for example. To learn about how to customize these Reader-mode AMP templates, please
     * see: https://amp-wp.org/documentation/how-the-plugin-works/classic-templates/
     * 🚫🚫🚫
     *
     * @package AMP
     */
    
    /**
     * Context.
     *
     * @var AMP_Post_Template $this
     */
    Plugin Support Milind More

    (@milindmore22)

    Hello @aniads

    No, the code comment is not required

    Thread Starter aniads

    (@aniads)

    Thank you.
    Now it works, but have found another problems (depending on where & how am I trying to modify the footer). Please have a look here:
    https://wordpress.org/support/topic/amp-next-page/

    Plugin Support Milind More

    (@milindmore22)

    Yes, My colleague will respond to you on that topic, in meantime be sure to share your experience using AMP plugin.

    I’ll mark this as resolved. Feel free to open a new support topic if you require any further assistance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How can I modify footer.php (amp/templates) with my own plugin or child theme?’ is closed to new replies.