Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

If you have a theme that for instance has a blog, front page and misc pages is it possible to have more than one theme customizer, so that you can provide a live preview when editing styles?

My theme has a front page, and a blog. Other than the header and footer, the blog doesn't take much from the front page because of the type of theme it is. If I wanted to allow the users to edit both the front page and blog pages using the theme customizer, would I be able to run more than one customizer, so I have one for front page, and one for blog? This would allow users to have the ease of use of the theme customizer, along with the ajax live preview. I haven't seen this done as of yet.

I am guessing the norm in this situation would be to either offer an additional options page in the backend, or add sections to the theme customizer for the other pages(even though you wont be able to see changes in real time)

Can anyone give me advice on this particular situation?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This is not a complete solution and the code is not tested, but I it should be enough to give you a general idea of how to use the customizer for different pages.

// Add "Edit page with customizer" link to relevant pages
add_action('admin_bar_menu', function($bar) {
    if (is_home()) {
        $bar->add_node(array(
            'id' => 'some-id-1',
            'title' => 'Edit home page with customizer',
            'href' => admin_url( 'customize.php?url=/home'),
        ));
    }
    else {
        // Same as above, but change url=/home to some other page
        // and possibly add something like &customize-page-id=PAGE_ID
        // so that you can use the page id later.
    }
 });

 // Add customizer settings based on context passed from admin-bar
 add_action( 'customize_register', function() {
     if ($_GET['url'] == '/home') {
         // Add home page customizers
     }
     else {
         // Add other page customizer where setting names are based on
         // $_GET['customize-page-id'] so that to avoid conflicts
     }
 });
});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.