Enable Right Sidebar in WordPress all Post for Astra theme

Enable Right Sidebar in WordPress all Post for Astra theme
533 Views
0
(0)

Easy way to enable right sidebar in all wordpress post for astra theme add following code in your current themes functions.php file.

<?php
add_action( 'init','cxc_sidebar_add_func' );
function cxc_sidebar_add_func(){
   $args = array(
      'post_type'=> 'post',
      'orderby'    => 'ID',
      'post_status' => 'publish',
      'order'    => 'DESC',
      'posts_per_page' => -1
   );
   $result = new WP_Query( $args );
   if ( $result-> have_posts() ) : ?>
      <?php while ( $result->have_posts() ) : $result->the_post(); 
         update_post_meta( get_the_ID(), 'site-sidebar-layout', 'right-sidebar' ); 
      endwhile; 
   endif;
   wp_reset_postdata(); 
}
?>

How useful was this blog?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this blog.

As you found this blog useful...

Follow us on social media!

We are sorry that this blog was not useful for you!

Let us improve this blog!

Tell us how we can improve this blog?

Leave a comment

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