Good day, dear coding gurus.
added to the first sidebar that was in the skin, the code of the second (my-sidebar):
function themonic_widgets_init() { register_sidebar( array( 'name' => __( 'Main Sidebar', 'iconic-one' ), 'id' => 'themonic-sidebar', 'description' => __( 'This is a Sitewide sidebar which appears on posts and pages', 'iconic-one' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<p class="widget-title">', 'after_title' => '</p>', ) ); register_sidebar( array( 'name' => __( 'My Sidebar', 'iconic-one' ), 'id' => 'my-sidebar', 'description' => __( 'This is a Sitewide sidebar which appears on posts and pages3', 'iconic-one2' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<p class="widget-title">', 'after_title' => '</p>', ) ); } add_action( 'widgets_init', 'themonic_widgets_init' ); I copied the sidebar.php file and named it sidebar-second.php, made the following changes in it:
<?php if ( is_active_sidebar( 'my-sidebar' ) ) : ?> <?php dynamic_sidebar( 'my-sidebar' ); ?> некий контент <?php else : ?> некий контент <?php endif; ?> And in the file header.php wrote the following structure:
<?php if ( is_single() ) : ?> <?php $sidebar = get_post_meta($post->ID, "sidebar", true); // левый сайдбар get_sidebar($sidebar);?> <?php else : ?> <?php get_sidebar('second'); ?> <?php endif; // is_single() ?> I’m not a programmer, and I can’t understand why, if there is no “arbitrary field” value that a page can specify, it doesn’t pick up sidebar-second.php by default? What needs to be changed in order to pick up and output this sidebar, if a unique one is not connected, which is specified through the value of an arbitrary field?