title: How to register and show 2nd sidebar only if the screen is wider than 1682px in wordpress?
body: <p>I want to show a 336px width second sidebar (left side on all pages) for destop/tv screens wider than 1682px.</p>
  <p>If the second sidebar has its own class then I can hide it with the {display: none;} CSS tag inside the media query feature.</p>
  <p>Currently, my template only has 1 sidebar which can be shown either on the right side or left side. It is currently on the right side.</p>
  <p>This script is already present on my functions.php</p>
  <pre><code>
  /*-----------------------------------------------------------------------------------*/
  //  Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
  //  To override skeleton_widgets_init() in a child theme, remove the action hook and add your own
  //  function tied to the init hook.
  /*-----------------------------------------------------------------------------------*/
  
  if ( !function_exists( 'skeleton_widgets_init' ) ) {
  
  function skeleton_widgets_init() {
          // Area 1, located at the top of the sidebar.
          register_sidebar( array(
          'name' =&gt; __( 'Posts Widget Area', 'smpl' ),
          'id' =&gt; 'sidebar-1',
          'description' =&gt; __( 'Shown only in Blog Posts, Archives, Categories, etc.', 'smpl' ),
          'before_widget' =&gt; '&lt;div id=&quot;%1$s&quot; class=&quot;widget-container %2$s&quot;&gt;',
          'after_widget' =&gt; '&lt;/div&gt;',
          'before_title' =&gt; '&lt;h3 class=&quot;widget-title&quot;&gt;',
          'after_title' =&gt; '&lt;/h3&gt;',
      ) );
  
  
      // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
      register_sidebar( array(
          'name' =&gt; __( 'Pages Widget Area', 'smpl' ),
          'id' =&gt; 'sidebar-2',
          'description' =&gt; __( 'Shown only in Pages', 'smpl' ),
          'before_widget' =&gt; '&lt;div id=&quot;%1$s&quot; class=&quot;widget-container %2$s&quot;&gt;',
          'after_widget' =&gt; '&lt;/div&gt;',
          'before_title' =&gt; '&lt;h3 class=&quot;widget-title&quot;&gt;',
          'after_title' =&gt; '&lt;/h3&gt;',
      ) );
  
      // Area 3, located in the footer. Empty by default.
      register_sidebar( array(
          'name' =&gt; __( 'First Footer Widget Area', 'smpl' ),
          'id' =&gt; 'footer-widget-area-1',
          'description' =&gt; __( 'The first footer widget area', 'smpl' ),
          'before_widget' =&gt; '&lt;div class=&quot;%1$s&quot;&gt;',
          'after_widget' =&gt; '&lt;/div&gt;',
          'before_title' =&gt; '&lt;h3 class=&quot;widget-title&quot;&gt;',
          'after_title' =&gt; '&lt;/h3&gt;',
      ) );
  
      // Area 4, located in the footer. Empty by default.
      register_sidebar( array(
          'name' =&gt; __( 'Second Footer Widget Area', 'smpl' ),
          'id' =&gt; 'footer-widget-area-2',
          'description' =&gt; __( 'The second footer widget area', 'smpl' ),
          'before_widget' =&gt; '&lt;div class=&quot;%1$s&quot;&gt;',
          'after_widget' =&gt; '&lt;/div&gt;',
          'before_title' =&gt; '&lt;h3 class=&quot;widget-title&quot;&gt;',
          'after_title' =&gt; '&lt;/h3&gt;',
      ) );
  
      // Area 5, located in the footer. Empty by default.
      register_sidebar( array(
          'name' =&gt; __( 'Third Footer Widget Area', 'smpl' ),
          'id' =&gt; 'footer-widget-area-3',
          'description' =&gt; __( 'The third footer widget area', 'smpl' ),
          'before_widget' =&gt; '&lt;div class=&quot;%1$s&quot;&gt;',
          'after_widget' =&gt; '&lt;/div&gt;',
          'before_title' =&gt; '&lt;h3 class=&quot;widget-title&quot;&gt;',
          'after_title' =&gt; '&lt;/h3&gt;',
      ) );
  
      // Area 6, located in the footer. Empty by default.
      register_sidebar( array(
          'name' =&gt; __( 'Fourth Footer Widget Area', 'smpl' ),
          'id' =&gt; 'footer-widget-area-4',
          'description' =&gt; __( 'The fourth footer widget area', 'smpl' ),
          'before_widget' =&gt; '&lt;div class=&quot;%1$s&quot;&gt;',
          'after_widget' =&gt; '&lt;/div&gt;',
          'before_title' =&gt; '&lt;h3 class=&quot;widget-title&quot;&gt;',
          'after_title' =&gt; '&lt;/h3&gt;',
      ) );
  }
  
  /** Register sidebars by running skeleton_widgets_init() on the widgets_init hook. */
  
  add_action( 'widgets_init', 'skeleton_widgets_init' );
  
  }
  
  /** Next code follows from this point...
  </code></pre>
  <p>This is the code present on sidebar.php</p>
  <pre><code>&lt;?php
  /**
   * The Sidebar containing the primary blog sidebar
   *
   */
  
  // hide sidebars with sidebars=false custom field
  if (is_singular() &amp;&amp; get_post_meta($post-&gt;ID, &quot;sidebars&quot;, $single = true) ==  &quot;false&quot;) {
      return;
  }
  
  if ( is_active_sidebar( 'sidebar-1' ) ) {
          do_action('skeleton_before_sidebar');
          dynamic_sidebar( 'sidebar-1' );
          do_action('skeleton_after_sidebar');
  }
  
  ?&gt;
  </code></pre>
  <p>As per this guide, <a href="https://wordpress.stackexchange.com/questions/135403/display-sidebar-that-created-in-functions-php">https://wordpress.stackexchange.com/questions/135403/display-sidebar-that-created-in-functions-php</a> , I added the code of the first answer to the functions.php file</p>
  <pre><code>// 2nd Sidebar
  add_action( 'widgets_init', 'wpsites_add_widget' );
  
  function wpsites_add_widget() {
  
  register_sidebar(array(
  'name'=&gt;'Sidebar-Aries',
  'id' =&gt; 'sidebar-aries',
  'description' =&gt;'Display all the contents of sidebar at Aries page.',
  'before_widget' =&gt; '',
  'after_widget' =&gt; '',
  'before_title' =&gt; '',
  'after_title' =&gt; '',
  ));
  }
  </code></pre>
  <p>Then added the other code into the single.php file</p>
  <pre><code>&lt;?php
  /**
   * The Template for displaying all single posts.
   *
   * @package 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();
  
  &lt;?php if ( is_active_sidebar( 'sidebar-aries' ) ) : ?&gt;
  &lt;ul id=&quot;sidebar&quot;&gt;
      &lt;?php dynamic_sidebar( 'sidebar-aries' ); ?&gt;
  &lt;/ul&gt;
  &lt;?php endif; ?&gt;
  ?&gt;
  </code></pre>
  <p>Then I visited Appearance &gt; Widgets and checked if there is any new sidebar but there is none.</p>
  <p>I also tried the code from another question but it didn't work for me as well.</p>
  <p>Then I followed this guide - <a href="https://smallbusiness.chron.com/build-website-php-sidebar-60499.html" rel="nofollow noreferrer">https://smallbusiness.chron.com/build-website-php-sidebar-60499.html</a></p>
  <blockquote>
  <p>Step: 5 - Locate the lines of code that register the sidebars in
  &quot;functions.php&quot; -- they are usually near the top. Edit the code to
  make “register_sidebar” plural, and add a number “2” between the
  brackets in the line below, like this:</p>
  </blockquote>
  <p><code>if ( function_exists('register_sidebars') ) register_sidebars(2);</code></p>
  <blockquote>
  <p>Click &quot;Update File.&quot; The sidebar is now available by going to
  &quot;Appearance&quot; and then &quot;Widgets.&quot;</p>
  </blockquote>
  <p>But the code present on my functions.php looks a bit different and it didn't work.</p>
  <p>What should I do?</p>