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

Improve Front page detection for AMP pages. #1055

Open
6 tasks done
milindmore22 opened this issue May 30, 2022 · 0 comments
Open
6 tasks done

Improve Front page detection for AMP pages. #1055

milindmore22 opened this issue May 30, 2022 · 0 comments

Comments

@milindmore22
Copy link

We received a support topic on the AMP support forum regarding polylang homepage, after debugging we found out that it can be easily fixed by adding a amp parameter in skip list.

Prerequisites

  • This is not a usage question (Those should be directed to the community supported forum, unless this is a question about Polylang Pro in which case you should use the helpdesk).
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest master branch of Polylang and the latest WordPress version.
  • This bug happens with only Polylang plugin active
  • This bug happens with a default WordPress theme active
  • I can reproduce this bug consistently

Steps to reproduce the issue

  1. Set Static Frontpage for WordPress site.
  2. Add another language for front page.
  3. Choose "The language is set from the directory name in pretty permalinks" & "The front page URL contains the language code instead of the page name or page id"
  4. Install and Activate the AMP plugin
  5. Choose Transitional Mode or Reader Mode
  6. When you visit a language page it will be like https://example.com/pt/portugal-bettilt/amp/

Expected behavior and actual behavior

It should be https://example.com/pt/amp/

the front page detection logic should skip the page when the query contains an amp which can be fixed by adding amp in the list

wp-content/plugins/polylang/frontend/frontend-static-pages.php in the function is_front_page
before

$query = array_diff( array_keys( $query->query ), array( 'preview', 'page', 'paged', 'cpage', 'orderby' ) );

After adding amp

$query = array_diff( array_keys( $query->query ), array( 'preview', 'page', 'paged', 'cpage', 'orderby', 'amp' ) );

This should allow you to land on a short slug-like /pt/amp/ on the homepage.

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

No branches or pull requests

2 participants