Title: Jetpack Functions
Last modified: February 23, 2022

---

# Jetpack Functions

 *  Resolved [Tyrosh](https://wordpress.org/support/users/iskmogul/)
 * (@iskmogul)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/jetpack-functions/)
 * I’m trying to make it so that Jetpack related posts only display on the AMP endpoint
   pages of my site, and output a certain number of posts. Is there an easy way 
   to make the functions listed below play nice together and code them into my current
   child theme’s functions?
 * I would prefer to keep using the Legacy AMP theme if at all possible, in Reader
   mode.
 *     ```
       function jetpackme_remove_rp() {
           if ( class_exists( 'Jetpack_RelatedPosts' ) ) {
               $jprp = Jetpack_RelatedPosts::init();
               $callback = array( $jprp, 'filter_add_target_to_dom' );
   
               remove_filter( 'the_content', $callback, 40 );
           }
       }
       add_action( 'wp', 'jetpackme_remove_rp', 20 );
   
       if( function_exists('amp_is_request') && is_amp_endpoint() ) {
       function jetpackme_more_related_posts( $options ) {
           $options['size'] = 6;
           return $options;
       }
       add_filter( 'jetpack_relatedposts_filter_options', 'jetpackme_more_related_posts' );
       }
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Fellyph Cintra](https://wordpress.org/support/users/fellyph/)
 * (@fellyph)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/jetpack-functions/#post-15404791)
 * Hi [@iskmogul](https://wordpress.org/support/users/iskmogul/),
 * You can add a function to add content on the footer of your AMP page, for example:
 *     ```
       add_filter( 'amp_post_template_footer', function() {
       	echo do_shortcode( '[jetpack-related-posts]' );
       } );
       ```
   
 * I have tried using the function from jetpack but I didn’t have enough views on
   my test env.
 *  [Fellyph Cintra](https://wordpress.org/support/users/fellyph/)
 * (@fellyph)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/jetpack-functions/#post-15405090)
 * Hi [@iskmogul](https://wordpress.org/support/users/iskmogul/),
 * Just a small correction:
 *     ```
       add_action( 'amp_post_template_footer', function() {
       	echo do_shortcode( '[jetpack-related-posts]' );
       } );
       ```
   
 *  Thread Starter [Tyrosh](https://wordpress.org/support/users/iskmogul/)
 * (@iskmogul)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/jetpack-functions/#post-15405169)
 * just to clarify, I want the output to only display on AMP pages, but calling 
   the removerp bit overrides anything else. I tried making an if/else statement
   with the two functions which relied on amp_is_request, but it wouldn’t work for
   some reason.
 * I also tried adding the shortcode directly to the relevant amp file, but that
   didn’t work either.
    -  This reply was modified 4 years, 3 months ago by [Tyrosh](https://wordpress.org/support/users/iskmogul/).
 *  [Fellyph Cintra](https://wordpress.org/support/users/fellyph/)
 * (@fellyph)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/jetpack-functions/#post-15405258)
 * Hi [@iskmogul](https://wordpress.org/support/users/iskmogul/),
 * You can use in this case is_amp_endpoint to check the non-AMP version and remove
   the feature
 *     ```
       <?php
   
       function exclude_jetpack_related_from_non_amp( $options ) {
           if ( function_exists('amp_is_request') && ! amp_is_request() ) {
               $options['enabled'] = false;
           }
   
           return $options;
       }
   
       add_filter( 'jetpack_relatedposts_filter_options', 'exclude_jetpack_related_from_non_amp' );
       ```
   
 * I’m not so familiar with jetpack methods, but you can change the way to remove
   it.
 *  [Fellyph Cintra](https://wordpress.org/support/users/fellyph/)
 * (@fellyph)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/jetpack-functions/#post-15437150)
 * As we didn’t receive a response I’ll mark this as resolved.
 *  [Fellyph Cintra](https://wordpress.org/support/users/fellyph/)
 * (@fellyph)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/jetpack-functions/#post-15437155)
 * Feel free to open a [new support topic](https://wordpress.org/support/plugin/amp/#new-post)
   if you require any further assistance.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Jetpack Functions’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Fellyph Cintra](https://wordpress.org/support/users/fellyph/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/jetpack-functions/#post-15437155)
 * Status: resolved