changing Specific section background image in wordpress

Use the Customizer API ( Advanced Topics ) to a modify a dynamic background.


UPDATE

Eric Lewis just presented an idea last night that might make it possible to customize single post content, not just global theme options using Customizer. Check out Custom CSS per post in WordPress. He also shows how to add a button to the edit post page which brings up the the customizer in a modal window for faster AJAX previews.


Gist

add_action( 'admin_enqueue_scripts', function($hook_suffix) {
    if ( in_array( $hook_suffix, array( 'post.php', 'post-new.php' ) ) ) {
        wp_enqueue_script( 'customize-loader' );
    }
} );

add_action( 'post_submitbox_misc_actions', function() {
    $customize_url = add_query_arg(

        array(
            // current page
            'url' => urlencode( get_post_permalink() ),

            // custom url
            // 'url' => urlencode( home_url() . '/page-to-preview/' ),

            // deeplink to panel
            // 'autofocus' => array( 'panel' => 'widgets' )
        ),

        wp_customize_url()
    );

    ?><button class="load-customize"
              href="https://wordpress.stackexchange.com/questions/210330/<?php echo esc_url( $customize_url ) ?>"
              type="button">Show In Customizer</button>
    <?php
} );

There are also contextual controls if you want to target specific pages.


But I think the easiest way to use Advanced Custom Fields.

Leave a Comment