• Resolved xmp333

    (@xmp333)


    Hi,

    I’m trying to add a custom sidebar to a search archive template. get sidebar() function doesn’t seem to work. Is there a special ID or slug that should be the parameter? I’m simply using the sidebar’s name.

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello there @xmp333,

    hope you’re doing good today! πŸ™‚

    As this is basically an issue about the theme you’re using, you should contact theme authors about it, in their respective support channel.

    A little tip though, if there’s a sidebar.php file in your theme, then get_sidebar() should be enough, without any kind of IDs. Reference: https://developer.ww.wp.xz.cn/reference/functions/get_sidebar/

    Warm regards,
    Dimitris

    Thread Starter xmp333

    (@xmp333)

    Hi Dimitris,

    thanks for your answer, there is a default sidebar, which I can get with get_sidebar(), but that’s not the intention though. I’m using your widget, because I need custom one. πŸ™‚

    So any suggestions how to get the newly created custom one, how to put it in an archive template? Overriding doesn’t work for me as there is no option in the plugin to override sidebar on the search archive.

    Hello @xmp333,

    I misunderstood that a bit, please excuse me! πŸ™‚

    As long as there’s a sidebar in the search results page, then you should be able to replace it, using following the “Sidebar location” setting:

    and of course allow initial sidebar to be replaced:

    Warm regards,
    Dimitris

    Thread Starter xmp333

    (@xmp333)

    Hi Dimitris,

    tried this in the first place, but no result for search archive. πŸ™

    https://prnt.sc/jagv18

    Hey @xmp333

    That’s pretty strange… don’t you get any options in there?

    What’s the theme you’re using? Please advise!

    Have you tried to perform a conflict test on this? Meaning to:
    – grab a full website backup
    – deactivate all other plugins
    – check how that goes

    Warm regards,
    Dimitris

    Thread Starter xmp333

    (@xmp333)

    Hi Dimitris,

    I don’t have any results unfortunately. The theme is called ‘EXZO’ and it must be the reason – I think they tampered with the archives so no results will show up. I’ll have to stick with editing the search.php template :))

    Hey there! πŸ™‚

    This would need some custom coding indeed.
    Let me explain what worked in my tests:

    – find the ID of the new created sidebar (don’t insert any rules on it)

    fullscreen: https://monosnap.com/file/6oRufKuveRmKbdSvbapclEd5xIbyOW#

    – edit search.php and replace get_sidebar(); with the actual content of sidebar.php file

    – replace dynamic_sidebar( ‘sidebar-1’ ); (or whatever ID is using) with the ID found in first step, in my case:
    dynamic_sidebar( ‘cs-2’ );


    fullscreen: https://monosnap.com/file/wKKfBfWFDKgjsGU2TRUAeTCdUI2qNk#

    Keep in mind that I test with TwentySeventeen theme and you should actually create a child theme for these changes, so you can continue updating parent theme, without losing any changes.
    https://premium.wpmudev.org/blog/how-to-create-wordpress-child-theme/

    Warm regards,
    Dimitris

    Thread Starter xmp333

    (@xmp333)

    Hi Dimitris,

    I just had the time to implement it. Works superb, thanks for the excellent support!

    Awesome! I’m glad this worked well for you! πŸ™‚

    Cheers,
    Dimitris

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘get_sidebar()’ is closed to new replies.