AMP Social Sharing Button Code Placement

I am looking to edit the post template so that I can add in the code for social sharing on my website’s AMP pages. Can someone help me as to what file I need to edit in order to make this possible?

Reference link: https://ampbyexample.com/components/amp-social-share/
In case other people find this useful, there is also AddThis with similar instructions: https://www.addthis.com/academy/how-to-install-addthis-inline-share-buttons-on-amp-accelerated-mobile-pages/

Hello Tim,

Thanks for asking. :slight_smile:

To add te AMP share script tag, you can use following plugin.

Please note that the plugin I have shared is not official Themeco advice. It’s just a personal input that I have shared with you to help you get started. 3rd party plugins may cause some issues and we won’t be able to provide support in that scenario.

Thanks.

Could I do the same thing by actually editing a file? I was looking at the following file structure and editing the file in the location:

framework/views/integrity/_content-post-header.php

Hello Tim,

Yes, you are in a correct path. Just make sure that all your customizations were done in the child theme so that it will not be overwritten when there are theme updates. Assuming that you are using Integrity stack and has already set up the child theme, please do these steps below:
1] Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
2] Insert the following code into that new file

<?php

// =============================================================================
// VIEWS/INTEGRITY/_CONTENT-POST-HEADER.PHP
// -----------------------------------------------------------------------------
// Standard <header> output for various posts.
// =============================================================================

?>

<header class="entry-header">
  <?php if ( is_single() ) : ?>
  <h1 class="entry-title"><?php the_title(); ?></h1>
  <?php else : ?>
  <h2 class="entry-title">
    <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php x_the_alternate_title(); ?></a>
  </h2>
  <?php endif; ?>
  <?php x_integrity_entry_meta(); ?>
</header>

Of course, do not forget to add your amp codes.

3] Save the file named as _content-post-header.php
4] Upload this file to your server in the child theme’s folder wp-content/themes/x-child/framework/views/integrity/

Create the folder path in your child theme because it does not exist yet.

Please let us know if this works out for you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.