theme development - Doing context-aware previews in the WordPress Customizer

admin2025-06-04  51

Initially I was using active_callback to make my Customizer controls contextual in nature, and was satisfied with the kind product I had with it. But then I cam across this article about Content-aware previews in Customizer. It is awesome.

In that article, the author has used his own plugin to get the page value. I got everything from the JavaScript enqueued for the controls and the previews, what I didn't get is; what could be the page value for a post or a page or a custom post type here.

$page = Login_Designer()->get_login_designer_page();

Is anyone doing something similar with Customizer? Please share how this can be doable with the different page types.

Initially I was using active_callback to make my Customizer controls contextual in nature, and was satisfied with the kind product I had with it. But then I cam across this article about Content-aware previews in Customizer. It is awesome.

In that article, the author has used his own plugin to get the page value. I got everything from the JavaScript enqueued for the controls and the previews, what I didn't get is; what could be the page value for a post or a page or a custom post type here.

$page = Login_Designer()->get_login_designer_page();

Is anyone doing something similar with Customizer? Please share how this can be doable with the different page types.

Share Improve this question asked Aug 5, 2018 at 8:20 BheemsenBheemsen 7710 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Since the code is using get_permalink( $page ), I would guess that $page holds an ID.

https://developer.wordpress/reference/functions/get_permalink/

In my opinion, it's not always a good thing to switch the preview to another page for the user.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749023741a315709.html

最新回复(0)