How to inject custom code in AMP pages when using TagDiv mobile theme

Posted in: Newspaper
Post count: 12

Hi,

we’re upgrading our theme to the latest version (10.4). After some fine tuning, we’re now trying to fix some issues concerning AMP and the mobile theme.
In particular, we would like to inject some custom code in the following locations:
– head
– after body tag is opened
– before body tag is closed

To do so, we have tried to use the standard hooks such as amp_post_template_head, amp_post_template_footer, amp_post_template_body_open but none of them are working.
We did some investigation and it looks like the mobile theme is bypassing the standard AMP implementation, indeed the mobile theme code for AMP can be found at wp-content/plugins/td-composer/mobile

We were wondering what’s the recommended way to inject our custom code, as we don’t want to directly edit the files of the plugin. Do you have any suggestion?

For your information, we have the following setup:
– latest version of Newspaper theme
– a child theme (Newspaper-child)
– mobile theme enabled only for AMP pages

Thanks

Post count: 12

Sorry to up this post but we didn’t get answer so far. Thank you

Post count: 21065

Hello!

You can try to inject the code in these files:
wp-content/plugins/td-composer/mobile/header-amp.php
wp-content/plugins/td-composer/mobile/footer-amp.php

But, please note that any change you make in the files after update will be overwritten and you have to make the changes again. Better save the code somewhere and then apply it again after update.

Hope that helps you somehow!

Thank you!

Post count: 12

Thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.