Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Robin Cornett

    (@littlerchicken)

    From the screenshot, it looks like the buttons are outputting, but not the styles. I’ve not used AMP myself, so not sure how to add custom styles to that, but that is where you need to look. Doing some searching, it appears that the Glue for Yoast SEO & AMP plugin gives an easy way to add custom CSS, which may be easier than adding it via code.

    Thread Starter Camilo

    (@camilo517)

    I use the official AMP plugin. @littlerchicken
    https://es.www.ads-software.com/plugins/amp/

    I think that if your plugin doesn’t work well with AMP it shouldn’t show anything ??

    Plugin Author Robin Cornett

    (@littlerchicken)

    The plugin does not output in specific situations handled by Core WordPress functions, such as feeds. If AMP is added into Core, I can look into adding support for it into the plugin.

    In the meantime, you can add some code to your site to prevent the buttons outputting in AMP. Looking at the documentation, this should work (not tested, because I don’t use AMP):

    add_filter( 'scriptlesssocialsharing_can_do_buttons', 'prefix_prevent_scriptless_amp' );
    /**
     * Do not output Scriptless buttons on AMP posts.
     *
     * @param boolean $can_do_buttons
     * @return boolean
     */
    function prefix_prevent_scriptless_amp( $can_do_buttons ) {
    	if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint()  ) {
    		return false;
    	}
    
    	return $can_do_buttons;
    }

    You can add this to your theme’s functions.php file or wherever you keep similar code. Please make sure you back up your files and practice safe coding.

    Thread Starter Camilo

    (@camilo517)

    I have used your code and they still appear @littlerchicken

    Plugin Author Robin Cornett

    (@littlerchicken)

    I suspect there is another issue at play here. That code is from the AMP documentation.

    I’ve now tested Scriptless with the Twenty Nineteen theme and the AMP plugin. In both Standard and Transitional modes, the buttons display and are styled properly, with the plugin CSS automatically added to the amp-custom.css file. The code example I provided does prevent the buttons being output at all. In reader mode, it appears that the code example is not needed at all, as the buttons are not output without the code.

    Since the buttons are present for you, I’m guessing you are in Standard or Transitional mode; the issue appears to be at the CSS level. I know there is a limit to how much CSS is allowed with AMP; one possibility is that you are over that limit.

    If the filter is not working, you may want to try a later priority on it, as that suggests you may have another instance of the filter running which is overriding this. You may need to try more in depth troubleshooting, such as reverting to a default theme. As far as I can tell, the issue is not with the Scriptless plugin.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘AMP’ is closed to new replies.