This topic has 2 replies, 3 voices, and was last updated 9 years by tstrickland415.
-
Author
-
January 5, 2015 at 16:44 #41030RYParticipant
Hi ,
I want to create / add another custom sidebar for the archive page template which mean I create my own sidebar because Main sidebar already used for other page and I dont wanna use the same main sidebar to display. Currently I have registered new sidebar on child theme function.php. and I wanna know what’s the next step? Can you advice me on this.
Thank you 🙂
RY
January 8, 2015 at 16:44 #41324RaduModeratorHello,
Put this code in your kleo-child functions.php
COPY CODEif ( ! function_exists( 'archive_sidebar' ) ) { // Register Sidebar function archive_sidebar() { $args = array( 'id' => 'archive-sidebar', 'name' => __( 'Archive sidebar', 'kleo_framework' ), ); register_sidebar( $args ); } // Hook into the 'widgets_init' action add_action( 'widgets_init', 'archive_sidebar' ); } function add_before_my_siderbar() { ?> <?php if (is_archive()) { ?> <div class="sidebar sidebar-main col-sm-3 sidebar-right"> <div class="inner-content widgets-container"> <?php dynamic_sidebar('archive-sidebar'); ?> </div><!--end inner-content--> </div><!--end sidebar--> <?php } ?> <?php } add_action( 'get_sidebar', 'add_before_my_siderbar' );
Let me know if it works.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJanuary 19, 2015 at 01:30 #42569tstrickland415ParticipantHey Radu, thanks for the code, it works but it only adds the new sidebar above the main sidebar. Is there a way to remove the old sidebar from showing on the Archive page, allowing for only the archive sidebar to show?
BTW, in case anybody searching is looking for ways to add different sidebars to different archive pages of custom post types, on line 23, instead of using
is_archive()
useis_post_type_archive(yourcustomposttype)
-
AuthorPosts
The forum ‘KLEO’ is closed to new topics and replies.