Last active
April 28, 2023 08:39
-
-
Save mattiasghodsian/a6ae8dfeb79f3769d3abb3563f2a6ef9 to your computer and use it in GitHub Desktop.
Wordpress - Make widgets inside widget area collapse for the Front-end user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Title: Widgets collapse for Front-end user | |
* Author Mattias Ghodsian | |
* Description: Make widgets inside widget area collapse for the Front-end user | |
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian | |
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5 | |
**/ | |
// register widget area | |
function mg_widgets_init() | |
{ | |
register_sidebar( array( | |
'name' => 'Blog Post', | |
'id' => 'blog-post', | |
'before_widget' => '<div class="col-widget" id="%1$s">', | |
'after_widget' => '</div>', | |
'before_title' => '<div class="col-widget-title">', | |
'after_title' => '</div>', | |
) ); | |
} | |
add_action( 'widgets_init', 'mg_widgets_init' ); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Title: Widgets collapse for Front-end user | |
* Author Mattias Ghodsian | |
* Description: Make widgets inside widget area collapse for the Front-end user | |
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian | |
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5 | |
**/ | |
<div id="blogSidebar"> | |
<?php if ( is_active_sidebar( 'blog-post' ) ) : ?> | |
<div class="row"> | |
<?php dynamic_sidebar( 'blog-post' ); ?> | |
</div> | |
<?php endif; ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Preview