Tagged: custom widget area, sidebar
I have a custom archive-artists.php file that I use for custom post type called artists. I want to use a custom widget area that I created in Appearance >. Widgets. I read the post at https://kriesi.at/support/topic/trying-to-echo-custom-sidebar-wiget-in-child-template/ and followed the instructions to add lines in sidebar.php and in my archive artists.php, but it is not working for me.
In sidebar.php
// Artist sidebars
if ($avia_config['currently_viewing'] == 'archive-artists' && dynamic_sidebar('Artists Mediums') ) : $default_sidebar = false; endif;
I added this just below
// general pages sidebars
if ($avia_config['currently_viewing'] == 'page' && dynamic_sidebar('Sidebar Pages') ) : $default_sidebar = false; endif;
Then on my archive-artists.php file I modified the sidebar code:
//get the sidebar
$avia_config['currently_viewing'] = 'archive-artists';
get_sidebar();
I also tried using ‘artists’ instead of ‘archive-artists’.
Can I do it this way or do I need to register a sidebar in my functions.php file and create a new sidebar.php?
Thank you!
Hi kallym!
Try adding this right above line 44.
if ( is_post_type_archive( 'your_post_type_goes_here' ) ) { $custom_sidebar = 'name_of_your_custom_sidebar'; }
Best regards,
Elliott
Thank you, that works!