• Resolved theflouredcamera

    (@theflouredcamera)


    I have a static homepage, but when I activate AMP for the homepage, it’s completely empty. The homepage is built all from widgets, is this the reason why?

    Is there any way I can set another page as my homepage for AMP?

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    It appears that you have the homepage assigned to a custom front page template that has a widget area on it. Since this custom page template is only located in the active theme and not the Reader theme, then the Reader theme doesn’t know anything about that template and so it renders the default page template. Therefore no widget area is rendered.

    If you want to use a Reader theme to render the homepage template with the same widget area, then you’ll need to a page template with the same name in the Reader theme. That would probably entail creating a child theme of Twenty Twenty-One.

    You can refer to our documentation for Adding Reader Themes, specifically first scenario.

    The other option would be to switch to Transitional mode (or Standard mode) in which case your active theme’s templates are fully used to create AMP pages the same as your non-AMP pages. This depends on your theme being AMP-compatible (at least compatible enough that it works when any custom JS is stripped out).

    • This reply was modified 5 years, 2 months ago by Weston Ruter.
    Plugin Author Weston Ruter

    (@westonruter)

    (Your site renders a blank screen when JS is turned off, so your theme is likely not going to be suitable for Transitional/Standard mode without some work.)

    Thread Starter theflouredcamera

    (@theflouredcamera)

    Hi Weston, thanks for responding so quickly!

    I created a child theme for Twenty-Twenty One, but I’m not seeing it as an option when I go back to my AMP reader settings?

    Plugin Author Weston Ruter

    (@westonruter)

    Did you add AMP: true to the style.css as mentioned in the aforementioned docs?

    Thread Starter theflouredcamera

    (@theflouredcamera)

    Ah my bad! I was reading the wrong documentation, thanks Weston!

    Thread Starter theflouredcamera

    (@theflouredcamera)

    Hi Weston, sorry and following up again!

    So I was able to do all of the above on my staging site, create a custom Twenty Twent One child theme, activated it in Reader, and created a page template with the same name under the child theme folder. However, the page still appears the same as before. Do you think it’s due to the widgets that are from the non-AMP theme?

    Plugin Author Weston Ruter

    (@westonruter)

    Oh, my apologies. I neglected to remember that widgets as a whole are disabled in Reader mode. The reason is that they are configured for the active theme and we don’t provide a way to manage the widget areas for the Reader theme. If you open the Customizer for the AMP version of the page in fact you’ll see that the “Widgets” panel is disabled entirely. Disabling widgets in Reader mode was simpler than trying to figure out a way to present users with a way of managing widgets in the active theme and Reader theme at the same time, without there being a mechanism in WordPress core for a “widget group” that could be shared between the two themes.

    I’m not sure of the best way forward. Something you could try is suspending the widget suppression just when you are rendering the sidebar in your custom template. Let’s say your sidebar has the ID of front-page, you could try code like this:

    if ( PHP_INT_MAX === has_filter( 'sidebars_widgets', '__return_empty_array' ) ) {
    	remove_filter( 'sidebars_widgets', '__return_empty_array', PHP_INT_MAX );
    	dynamic_sidebar( 'front-page' );
    	add_filter( 'sidebars_widgets', '__return_empty_array', PHP_INT_MAX );
    }

    @theflouredcamera As we haven’t received a response, I’ll mark this as resolved. Feel free to open a new support topic if you continue to encounter issues, or reopen this topic and we’d be happy to assist. Thank you!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘AMP Static Homepage Empty’ is closed to new replies.