• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Add an ID to Primary Sidebar

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Add an ID to Primary Sidebar

This topic is: resolved

Tagged: id, javascript, primary sidebar, Sidebar

  • This topic has 3 replies, 2 voices, and was last updated 10 years, 7 months ago by Genesis Developer.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • October 30, 2014 at 11:09 am #129909
    nickhempsey
    Member

    Hey Gang,

    What's the filter for adding an ID to the Primary Sidebar. I need the ID for javascript purposes.

    I feel like I've done this before, but I can't track down the project I did it in.

    Thanks!

    Nick

    October 30, 2014 at 11:44 am #129915
    Genesis Developer
    Member

    Try this once

    add_filter( 'genesis_attr_sidebar-primary', 'gd_attributes_sidebar_primary' );
    function gd_attributes_sidebar_primary( $attributes ){
      $attributes['id']     = 'sidebar';
    
      return $attributes['class'];
    }

    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    October 30, 2014 at 12:03 pm #129916
    nickhempsey
    Member

    right right right. Thanks!

    One adjustment though.

    add_filter( 'genesis_attr_sidebar-primary', 'gd_attributes_sidebar_primary' );
    function gd_attributes_sidebar_primary( $attributes ){
      $attributes['id']     = 'sidebar';
    
      return $attributes;  // Removed ['class']
    }
    October 30, 2014 at 8:35 pm #129959
    Genesis Developer
    Member

    yes right. I did copy & paste from my code. So ['class'] is included with return value.


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble