I’m having trouble with my WordPress site using the Myself theme. The sidebars work fine on most pages, including the blog section. But when I do a search, the results page shows up without any sidebar.
I’ve set up two sidebars in the widgets area: ‘sidebar’ and ‘Optional Sidebar’. The Optional Sidebar is specifically for the blog and shows up correctly there.
The search results use search.php in the theme folder. It has this code:
if ( myself_is_sidebar_enable() ) {
get_sidebar();
}
I can’t find any option in the admin panel to turn on the sidebar for search results. I’ve tried checking and unchecking various options in the sidebar widget settings, but nothing seems to work.
Has anyone else run into this issue? How can I get the sidebar to show up on the search results page?
Have you considered using a plugin to address this issue? I’ve had success with ‘Custom Sidebars’ in similar situations. It allows you to assign specific sidebars to different page types, including search results.
Another approach is to check your theme’s customizer settings. Some themes have options to control sidebar visibility for various page types hidden in there.
If those don’t work, you might need to dive into the theme files. Look for a conditional statement in search.php or sidebar.php that might be excluding the sidebar on search pages. Sometimes it’s a simple oversight in the theme’s code.
Remember to back up your site before making any changes, especially if you’re editing theme files directly.
hey Tom, have u checked the myself_is_sidebar_enable() function? It might be returning false for search pages. try adding a conditional statement in search.php to force display the sidebar:
if ( is_search() ) {
get_sidebar();
} elseif ( myself_is_sidebar_enable() ) {
get_sidebar();
}
this should make the sidebar appear on search results. lmk if it works!
I’ve encountered a similar issue with the Myself theme before. The problem likely stems from how the theme handles sidebars for different page types.
One workaround I found effective was modifying the myself_is_sidebar_enable() function in the theme’s functions.php file. You can add a condition to explicitly enable the sidebar for search results:
function myself_is_sidebar_enable() {
// ... existing function code ...
if ( is_search() ) {
return true;
}
// ... rest of the function ...
}
This should force the sidebar to display on search result pages. Remember to create a child theme before making any changes to avoid losing modifications during theme updates.
If you’re not comfortable editing theme files, reaching out to the theme developer for support might be a good alternative. They may have insights specific to the Myself theme’s structure.