Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ?amp=1 while using pretty permalink or hooks to use custom amp url #353

Closed
Asif2BD opened this issue Mar 28, 2016 · 4 comments
Closed

Comments

@Asif2BD
Copy link

Asif2BD commented Mar 28, 2016

For one of my project I need to use url with argument, so ?amp=1 is fine while the project use pretty permalink.

Is there a hook to change amp url? I could edit source in amp.php but need a hook so could remain valid after plugin update. And here canonical url needs to update as well, so hook is best. I could not find a hook so far, please direct me if we already have one, or let'r make it a feature addition, and bring it on.

@mjangda
Copy link
Contributor

mjangda commented Mar 28, 2016

@mjangda mjangda closed this as completed Mar 28, 2016
@Asif2BD
Copy link
Author

Asif2BD commented Mar 28, 2016

Thanks a ton @mjangda for pointing this out.
Then I just want to have ?amp=1 as my canonical, instead of /amp/. How do I do that with this 'amp_get_permalink' filter. Sorry for bugging, and Thanks in advance!

@mjangda
Copy link
Contributor

mjangda commented Mar 28, 2016

Just using that filter should do it since we use the function internally to get the AMP URL for each post. If not, it might be a bug.

I guess we could provide another filter in this function that runs before we generate the AMP URL (amp_pre_get_permalink) so it's easier to modify (in your case, you have to strip off the amp/ and replace it with ?amp=, which seems annoying.)

@Asif2BD
Copy link
Author

Asif2BD commented Mar 29, 2016

Actually in my case my site has a m.site, for serving mobile traffic automatically, and that filter is done from server. And as our link structure is like domain.com/category/post-title/, so with amp it becomes domain.com/category/post-title/amp/ which I find that very hard to filter from nginx.conf and stop the redirection for mobile device. But if I could use argument like ?amp=1 its easier for me to filter and stop redirection.

And yes this 'amp_get_permalink' happens on the top, and adding filter to modify it does not work on header. I think the plugin should have a option page, very simple one, and we should be able to change amp url as we want, and you could use that on 'amp_pre_get_permalink'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants