Tagged: category, custom sidebar
-
AuthorPosts
-
October 18, 2018 at 4:25 pm #1023433
Hey folks.
Trying to apply a custom sidebar for specific archive categories. Found the below snippet here, which is supposed to be applied to sidebar.php – so I copied sidebar.php to my child theme folder and added it, and it broke the site. In the example, artist is the category, and Directory Sidebar is the name of the custom sidebar.
Help?
Thanks!
if (is_archive(artist)) {
dynamic_sidebar(‘Directory Sidebar’);
$default_sidebar = false;
}October 18, 2018 at 7:25 pm #1023590Hey interage,
What was the error?
Can you please check server log for error text?
Best regards,
VictoriaOctober 18, 2018 at 8:06 pm #1023607Header and main menu showed up fine, but body content and sidebar were blank.
October 18, 2018 at 8:15 pm #1023613I’ll turn on wp debug and see what errors it throws! TY!
October 18, 2018 at 8:25 pm #1023621OK – first off, I miscoded it…
It should have been category, not archive. But it’s still throwing an error.
Here’s the proper code:
if (is_category(artist)) {
dynamic_sidebar(‘Directory Sidebar’);
$default_sidebar = false;Here’s the error it throws:
Parse error: syntax error, unexpected ‘Sidebar’’ (T_STRING) in (site) /wp-content/themes/enfold-child/sidebar.php on line 76
That’s this line:
dynamic_sidebar(‘Directory Sidebar’);
Thanks!
M
October 19, 2018 at 11:43 pm #1024239Any luck?
Thanks!
October 21, 2018 at 6:21 pm #1024547Hi interage,
Here is how to use the functions:
https://codex.wordpress.org/Function_Reference/dynamic_sidebar
This line should be:dynamic_sidebar('directory-sidebar');
If you need further assistance please let us know.
Best regards,
VictoriaOctober 21, 2018 at 6:22 pm #1024549Hi interage,
Here is how to use the functions:
https://codex.wordpress.org/Function_Reference/dynamic_sidebar
This line should be:dynamic_sidebar('directory-sidebar');
If you need further assistance please let us know.
Best regards,
VictoriaOctober 22, 2018 at 3:57 am #1024657Thank you so much!!!
FYI – Josue posted here back in 2013 using two words for the sidebar name:
https://kriesi.at/support/topic/sidebar-functionality-and-assigning-sidebar-to-category-archive-page/#post-175388You might want to edit that!
Thanks again.
October 22, 2018 at 6:32 pm #1025042Hi interage,
Glad you got it working for you! :)
If you need further assistance please let us know.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.