Customizer add query to preview URL

In some part of our customizer we are redirecting users to some specific pages.

var url = ‘https://test.com/specific-page’;
api.previewer.previewUrl.set( url );

We want to pass a custom query along with URL but it’s not working as expected. We tried following codes.

Code 1: (not working at all)

_.extend( api.previewer.query, { custom_query: 123 } )
api.previewer.previewUrl.set( getFrontendPreviewUrl() );

Code 2: (it works but after several reloads, it adds several ? to url)

api.previewer.previewUrl.set( api.previewer.previewUrl() + ‘?custom_query=’ + 123);

Read more here:: Customizer add query to preview URL

Leave a Reply

Your email address will not be published. Required fields are marked *