#70453
Nick
Keymaster
WP Royal Team

Hi,

Important: before adding the code, please make a backup. You can use this plugin – https://wordpress.org/plugins/updraftplus/ or make sure to test it on a development or staging environment before running it on a live website.

To set Right Sidebar for all pages you will need to insert the following code at the end the functions.php file. Then you need to visit your website home page and refresh it once (this will update all pages with the custom value). After that you can remove the code from functions.php file.


$args = array(
    'post_type' => 'page',
    'post_status' => 'publish',
    'posts_per_page' => -1
);
$all_pages = new WP_Query( $args );
if ( $all_pages->have_posts() ) {
    while ( $all_pages->have_posts() ) {
        $all_pages->the_post();
        update_post_meta(get_the_ID(), 'show_page_sidebar', 'rsidebar');
    }
    wp_reset_postdata();
}

Kind Regards