@creativemindssolutions Do you mind temporarily disabling WP Rocket and checking again? It could be the cause of the additional “/” at the end of your AMP URLs. If that doesn’t work please send me a list of other plugins in use, or you can try deactivating them temporarily before checking.
If the above doesn’t work we can troubleshoot further or add a filter to force the ?amp version of the AMP link.
Hi James
I’m the client of @creativemindssolutions with the 404 issue.
Since I’ve installed AMP a couple of days ago, all pages/posts work fine with AMP. Except for the terms pages of CM Tooltip Glossary.
As stated above, url + “amp/” gives a 404 error, url + “?amp” works fine.
Deactivating WP Rocket is not making any difference in behaviour.
Regards
Winnie
Try flushing your rewrite rules. You can do this by visiting your permalinks admin screen.
Hi Weston
Already done that (a couple of times).
Alas
Something is not working as expected. The URL you gave is for a page and yet it is ending in /amp/ when it should be ending in ?amp.
So instead of https://debeleggersgids.be/woordenboek/aandelenklasse/amp/
It should be https://debeleggersgids.be/woordenboek/aandelenklasse/?amp
This is because pages and other hierarchical post types need to use the query parameter.
Where the amphtml link is coming from is the amp_add_amphtml_link() function here:
https://github.com/ampproject/amp-wp/blob/d9b4ccdecac6e25942c83938bac1d9537f370661/includes/amp-helper-functions.php#L185-L186
And then the amp_get_permalink() function, which should be running this logic: https://github.com/ampproject/amp-wp/blob/d9b4ccdecac6e25942c83938bac1d9537f370661/includes/amp-helper-functions.php#L101-L117
Because is_post_type_hierarchical( get_post_type( $post_id ) ) should be false.
That is where I suggest debugging.
is_post_type_hierarchical( get_post_type( $post_id ) ) returns false for both ‘post’ and ‘glossary’.
What I did find out is that empty ( $structure ) is returning 1. Basically this means the option ‘permalink_structure’ is somewhere set to true.
But if empty( $structure ) is returning true then that should be forcing the query var to be used as opposed to the endpoint. 😐
After some further testing I found out there appears to be no issue with using ‘/amp/’ instead of ‘/?amp’. All posts/pages work with both endpoints perfectly.
The main issue is that CM Tooltip Glossary is not accepting ‘/amp/’ as an endpoint for terms.
As a temp solution I’ve changed a small bit of code in amp-helper-functions.php
if ( $use_query_var ) { (rule 119)
changed into
if ( $use_query_var || 'glossary' === get_post_type( $post_id )) {
So now I have ‘/amp/’ for all posts/pages, and ‘/?amp’ for the CM Tooltip Glossary terms. @creativemindssolutions, could you look into this? I have no idea where to start.
-
This reply was modified 6 years, 11 months ago by
shineblue.
Yes, of course. My mistake…
It is returning false, which it should.