While you can modify the AMP Reader mode templates to add the same code, probably a better approach is to inject the breadcrumbs with a the_content
filter. Without the is_amp_endpoint()
check even, this will also add the breadcrumbs to any theme as well so you don’t have to modify the theme files:
add_filter( 'the_content', static function ( $content ) {
if (
function_exists( 'yoast_breadcrumb' )
&&
function_exists( 'is_amp_endpoint' )
&&
is_amp_endpoint()
) {
$content = yoast_breadcrumb( '<p id="breadcrumbs">','</p>', false ) . "\n\n$content";
}
return $content;
} );
Thank you for your time and help, I greatly appreciate it!
We tried to include this in the single.php file so that it would show up on all posts, but this unfortunately did not work for us. I wonder if maybe it is an issue with the cache or our theme. Thank you very much anyway for your time and help! We’ll keep trying. In the meanwhile, this is good enough without the breadcrumbs. We are so happy with how it helped to speed up the page!
Very best wishes,
Dory
Putting this plugin code in the single.php
file would probably not be correct. It would be better to put it in a separate plugin that you activate separately.
For example, create a file like wp-content/plugins/learn2love-amp-breadcrumbs.php
and put in the file:
<?php
/**
* Plugin Name: learn2love AMP Breadcrumbs
*/
add_filter( 'the_content', static function ( $content ) {
if (
function_exists( 'yoast_breadcrumb' )
&&
function_exists( 'is_amp_endpoint' )
&&
is_amp_endpoint()
) {
$content = yoast_breadcrumb( '<p id="breadcrumbs">','</p>', false ) . "\n\n$content";
}
return $content;
} );
Then activate the plugin.
Thank you for sharing this with me, I greatly appreciate your time and help
We had some trouble creating a new plugin, but just placed the add_filter
command instead the functions.php file of the theme and it seems to work just fine.
I greatly appreciate your time and help!
Dory
Yes, putting it in the theme’s functions.php
will work for the current Reader mode. However, when/if you switch to use a new Reader theme in v2.0 then you’ll need to move it to a plugin.
Okay, I understand. Thank you very much for this! I appreciate your time and help.
We tried uploading the plugin as a .PHP file and it resulted in an error saying that only .zip files can be installed. We will try to compress it then and reupload to be compatible with the next release. I greatly appreciate all of your time in helping me with this tool,
Dory
Did you try and compress the php file into a .zip file and upload? Let us know how you get on after doing so.