I wish to present a 336px width second sidebar (left aspect on all pages) for destop/television screens wider than 1682px.
If the second sidebar has its personal class then I can conceal it with the {show: none;} CSS tag contained in the media question function.
At the moment, my template solely has 1 sidebar which might be proven on the fitting aspect or left aspect. It’s at present on the fitting aspect.
This script is already current on my features.php
/*-----------------------------------------------------------------------------------*/
// Register widgetized areas, together with two sidebars and 4 widget-ready columns within the footer.
// To override skeleton_widgets_init() in a toddler theme, take away the motion hook and add your personal
// operate tied to the init hook.
/*-----------------------------------------------------------------------------------*/
if ( !function_exists( 'skeleton_widgets_init' ) ) {
operate skeleton_widgets_init() {
// Space 1, positioned on the prime of the sidebar.
register_sidebar( array(
'title' => __( 'Posts Widget Space', 'smpl' ),
'id' => 'sidebar-1',
'description' => __( 'Proven solely in Weblog Posts, Archives, Classes, and many others.', 'smpl' ),
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Space 2, positioned under the Main Widget Space within the sidebar. Empty by default.
register_sidebar( array(
'title' => __( 'Pages Widget Space', 'smpl' ),
'id' => 'sidebar-2',
'description' => __( 'Proven solely in Pages', 'smpl' ),
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Space 3, positioned within the footer. Empty by default.
register_sidebar( array(
'title' => __( 'First Footer Widget Space', 'smpl' ),
'id' => 'footer-widget-area-1',
'description' => __( 'The primary footer widget space', 'smpl' ),
'before_widget' => '<div class="%1$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Space 4, positioned within the footer. Empty by default.
register_sidebar( array(
'title' => __( 'Second Footer Widget Space', 'smpl' ),
'id' => 'footer-widget-area-2',
'description' => __( 'The second footer widget space', 'smpl' ),
'before_widget' => '<div class="%1$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Space 5, positioned within the footer. Empty by default.
register_sidebar( array(
'title' => __( 'Third Footer Widget Space', 'smpl' ),
'id' => 'footer-widget-area-3',
'description' => __( 'The third footer widget space', 'smpl' ),
'before_widget' => '<div class="%1$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Space 6, positioned within the footer. Empty by default.
register_sidebar( array(
'title' => __( 'Fourth Footer Widget Space', 'smpl' ),
'id' => 'footer-widget-area-4',
'description' => __( 'The fourth footer widget space', 'smpl' ),
'before_widget' => '<div class="%1$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
/** Register sidebars by working skeleton_widgets_init() on the widgets_init hook. */
add_action( 'widgets_init', 'skeleton_widgets_init' );
}
/** Subsequent code follows from this level...
That is the code current on sidebar.php
<?php
/**
* The Sidebar containing the first weblog sidebar
*
*/
// conceal sidebars with sidebars=false customized subject
if (is_singular() && get_post_meta($post->ID, "sidebars", $single = true) == "false") {
return;
}
if ( is_active_sidebar( 'sidebar-1' ) ) {
do_action('skeleton_before_sidebar');
dynamic_sidebar( 'sidebar-1' );
do_action('skeleton_after_sidebar');
}
?>
As per this information, Show sidebar that created in features.php , I added the code of the primary reply to the features.php file
// 2nd Sidebar
add_action( 'widgets_init', 'wpsites_add_widget' );
operate wpsites_add_widget() {
register_sidebar(array(
'title'=>'Sidebar-Aries',
'id' => 'sidebar-aries',
'description' =>'Show all of the contents of sidebar at Aries web page.',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));
}
Then added the opposite code into the one.php file
<?php
/**
* The Template for displaying all single posts.
*
* @package deal WordPress
* @subpackage skeleton
* @since skeleton 0.1
*/
get_header();
do_action('skeleton_before_content');
get_template_part( 'loop', 'single' );
do_action('skeleton_after_content');
get_sidebar();
get_footer();
<?php if ( is_active_sidebar( 'sidebar-aries' ) ) : ?>
<ul id="sidebar">
<?php dynamic_sidebar( 'sidebar-aries' ); ?>
</ul>
<?php endif; ?>
?>
Then I visited Look > Widgets and checked if there’s any new sidebar however there’s none.
I additionally tried the code from one other query however it did not work for me as effectively.
Then I adopted this information – https://smallbusiness.chron.com/build-website-php-sidebar-60499.html
Step: 5 – Find the strains of code that register the sidebars in
“features.php” — they’re normally close to the highest. Edit the code to
make “register_sidebar” plural, and add a quantity “2” between the
brackets within the line under, like this:
if ( function_exists('register_sidebars') ) register_sidebars(2);
Click on “Replace File.” The sidebar is now obtainable by going to
“Look” after which “Widgets.”
However the code current on my features.php seems a bit completely different and it did not work.