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

Documentation: Call to wp_body_open() is necessary for Audience preview to work #275

Open
kevinlangleyjr opened this issue Sep 8, 2021 · 1 comment

Comments

@kevinlangleyjr
Copy link
Contributor

When viewing an Altis site on the frontend, the audience preview in the WP Admin Bar does not work as expected unless you use wp_body_open() which will render the admin bar at the top of the <body> instead of appending it before the end of the <body> element.

Specifically, here is where we are getting the element by ID to then render the React components.

On the Altis demo site, the admin bar is output as the first child element of the body, so when this script is run the admin bar is already able to be selected. On two client sites, the admin bar is output as part of wp_footer() in the footer and therefore this selector is run before the admin bar is rendered and therefore returns without rendering the menu correctly.

I think we should document somewhere that in order for audience previews to work, it is required to use wp_open_body() so the admin bar is rendered before the audience preview script is included.

@roborourke
Copy link
Contributor

Thanks @kevinlangleyjr, we need to connect up when the audience preview script is output and where the admin bar is output. Is this just down the theme and whether it uses that function?

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