Title: AMP reporting many errors
Last modified: April 22, 2022

---

# AMP reporting many errors

 *  Resolved [richard1250](https://wordpress.org/support/users/richard1250/)
 * (@richard1250)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/)
 * I have sent the data to you. The resulting Support UUID is ampwp-89ce343a-bdf0-
   58cd-b8d9-c81998062645 The most serious problem is the fact that my theme GeneratePress
   in not compatible with AMP. However I cannot change the theme since I made too
   many necessary changes to it over the years. Hope you can help me out and thanks!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Famp-reporting-many-errors%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Thread Starter [richard1250](https://wordpress.org/support/users/richard1250/)
 * (@richard1250)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15581803)
 * I have posted in the GeneratePress WP support forum and the problem was not resolved.
   I have emailed the author of GeneratePress several times and there was no reply.
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15581856)
 * Hello [@richard1250](https://wordpress.org/support/users/richard1250/)
 * Thank you for creating a support topic, GenratePress can be made AMP-compatible
   using a [small plugin](https://github.com/tomusborne/amp-for-generatepress) they
   created.
 * We checked your support data it seems you are using the child theme of GeneratePress.
   which created a validation error.
 * The source of error seems to be `functions.php` file with the function `add_twitter_cards`
   function having an invalid attribute.
 * I will recommend checking twitter cards tags one more time from the [official documentation](https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started)
   and validate once added on twitter [card validator](https://cards-dev.twitter.com/validator)
 * Another error about Generatepress adding script should be fixed by AMP for the
   GeneratePress plugin.
 * if that didn’t help, please add the following code to the child themes functions.
   php file.
 *     ```
       add_filter( 'generate_print_a11y_script', 'amp_remove_a11y_script' );
       /**
        * Remove the a11y script from GeneratePress.
        *
        * @param bool $print Whether to print the script or not.
        */
       function amp_remove_a11y_script( $print ) {
           if ( function_exists( 'amp_is_request' ) && amp_is_request() ) {
               return false;
           }
   
           return $print;
       }
       ```
   
 * Hope this helps!
 *  Thread Starter [richard1250](https://wordpress.org/support/users/richard1250/)
 * (@richard1250)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15583794)
 * Hi Milind
 * This is my Twitter card code in functions.php and I have no idea what’s wrong
   with it:
 * <meta name=”twitter:card” value=”summary_large_image” />
    <meta name=”twitter:
   title” value=”<?php echo $tc_title; ?>” /> <?php if($tc_image) { ?> <meta name
   =”twitter:image” value=”<?php echo $tc_image_thumb; ?>” />
 * Then the code you send me is not accepted by the file editor in WP. Any idea?
 * Thank you so much!
 * Best regards
    Richard
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15588037)
 * Hello [@richard1250](https://wordpress.org/support/users/richard1250/)
 * Sorry for the delayed response, it seems you are using `value` attribute while
   the Twitter docs mention `content` attribute
 * Can you please try the below code also please replace variable values for `$tc_title`,`
   $tc_exceprt` and `$tc_image_thumb` with yours values.
 *     ```
       add_action(
       	'wp_head',
       	function() {
       		$tc_title = get_the_title();
       		$tc_exceprt = strip_tags( get_the_excerpt() );
       		$tc_image_thumb = 'http://graphics8.nytimes.com/images/2012/02/19/us/19whitney-span/19whitney-span-articleLarge.jpg';
       		?>
       		<meta name="twitter:card" content="summary_large_image">
       		<meta name="twitter:creator" content="@RichardDetering">
       		<?php if ( ! empty( $tc_title ) ) { ?>
       			<meta name="twitter:title" content="<?php echo esc_attr( $tc_title ); ?>">
       		<?php } ?>
       		<?php if ( ! empty( $tc_exceprt ) ) { ?>
       			<meta name="twitter:description" content="<?php echo esc_attr( $tc_exceprt ); ?>">
       		<?php } ?>
       		<?php if ( ! empty( $tc_image_thumb ) ) { ?>
       		<meta name="twitter:image" content="<?php echo esc_attr( $tc_image_thumb ); ?>">
       			<?php
       		}
       	}
       );
       ```
   
 * The same code worked for me on [my test site](https://amp-support.rt.gw/template-sticky/?amp=1),
   also verified same on [twitter card validator](https://cards-dev.twitter.com/validator)
 * Hope this helps!
 *  Thread Starter [richard1250](https://wordpress.org/support/users/richard1250/)
 * (@richard1250)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15588765)
 * Thanks Milind! Question: “Replace variable values for $tc_title, $tc_exceprt 
   and $tc_image_thumb with your values.
    As far as I know these values are not 
   variable or am I wrong? Have unfortunately no idea what to replace them with.
   Do you know where I can find these values?
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15588798)
 * [@richard1250](https://wordpress.org/support/users/richard1250/)
 * Sorry for the confusion, I mean the variables (the ones you were using before),
   it’s up to you how you wanted to use Twitter cards (you easily find [examples of Twitter cards](https://instapage.com/blog/twitter-website-cards)
   by quick search)
 *  Thread Starter [richard1250](https://wordpress.org/support/users/richard1250/)
 * (@richard1250)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15588861)
 * Sorry Milind, am not a developer and I still don’t understand. Example the URL
   you gave me [http://graphics8.nytimes.com/images/2012/02/19/us/19whitney-span/19whitney-span-articleLarge.jpg](http://graphics8.nytimes.com/images/2012/02/19/us/19whitney-span/19whitney-span-articleLarge.jpg)
   in your coding should be replaced with what? Further $tc_title, and $tc_exceprt
   in your coding seem OK for me so they don’t need to be replaced I suppose? Sorry
   for my ignorance.
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15588942)
 * No problem Richard, I thought you have those variables that might be getting 
   values from somewhere in your code snippet.
 * In case no, then please use the updated code snippet below that uses the post’s
   feature image for the Twitter card.
 * You also need a default image path (currently it’s your image) if the post has
   no feature image set.
 *     ```
       add_action(
       	'wp_head',
       	function() {
       		$tc_title = get_the_title();
       		$tc_exceprt = strip_tags( get_the_excerpt() );
       		$tc_image_thumb = has_post_thumbnail() ? get_the_post_thumbnail_url() : 'https://richarddetering.com/wp-content/uploads/2020/01/richarddetering8.jpg';
       		?>
       		<meta name="twitter:card" content="summary_large_image">
       		<meta name="twitter:creator" content="@RichardDetering">
       		<?php if ( ! empty( $tc_title ) ) { ?>
       			<meta name="twitter:title" content="<?php echo esc_attr( $tc_title ); ?>">
       		<?php } ?>
       		<?php if ( ! empty( $tc_exceprt ) ) { ?>
       			<meta name="twitter:description" content="<?php echo esc_attr( $tc_exceprt ); ?>">
       		<?php } ?>
       		<?php if ( ! empty( $tc_image_thumb ) ) { ?>
       		<meta name="twitter:image" content="<?php echo esc_attr( $tc_image_thumb ); ?>">
       			<?php
       		}
       	}
       );
       ```
   
 * replace the previous code snippet with this one
 *  Thread Starter [richard1250](https://wordpress.org/support/users/richard1250/)
 * (@richard1250)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15589107)
 * Great and thanks Milind!
 *  Thread Starter [richard1250](https://wordpress.org/support/users/richard1250/)
 * (@richard1250)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15591296)
 * Great job Milind. The Twitter card works perfect and the error about the Child
   Theme disappeared. The only compatibility error still popping up is the one about
   GeneratePress which is the theme the child theme is based on. Is that a problem
   or can I ignore it? (By the way, it’s funny that you write exceprt in stead of
   excerpt in the coding).
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15591490)
 * [@richard1250](https://wordpress.org/support/users/richard1250/)
    You can ignore
   that error, it should not be a problem, Ha I just noticed that exceprt!! 😀
 *  Thread Starter [richard1250](https://wordpress.org/support/users/richard1250/)
 * (@richard1250)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15592025)
 * Thanks for your professional help. Highly appreciated!

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

The topic ‘AMP reporting many errors’ 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/)

 * 12 replies
 * 2 participants
 * Last reply from: [richard1250](https://wordpress.org/support/users/richard1250/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/amp-reporting-many-errors/#post-15592025)
 * Status: resolved