Display a slider in the 404 and search pages


Note :This snippet works only with the Classical style option. The Classical style option can be enabled in Appearance > Customize > Advanced > Theme Style. More about the theme style option here


Let’s say you have created a slider named “my-slider” and you want to display it in your 404 page or in your search pages. Since there’s no option to style those pages from the WP admin, you’ll have to code something.

Here’s a short snippet to do it.

Paste this code in the functions.php file of your Customizr theme or child theme.


Related Snippets you may also like


We can help you to implement this snippet

Coding is our job and we know WordPress inside and out. We can help you to customize your website with small chunks of code snippets like this one.

Send us your request and we'll get back to you quickly.



7 thoughts on “Display a slider in the 404 and search pages

  • redpete

    Thanks Marouane! That worked, with one minor addition; there was a missing end bracket for } for the first slider in line 8. When I tested it, it does display the slider, but not a full width slider. Normally I’d set this on the page/post under Slider Options, but there is no 404 page to edit in admin. I’m sure it can be set somehow with the “tc_slider_layout” hook, but I tried a couple of ways and failed. Do you know what the appropriate code would be?

    Thanks again for your help.

    • Marouane

      I don’t want to waste your time because I coudln’t test it but, if you want may be you can try this:

      //display in full width
      add_filter( 'tc_slider_layout' , 'force_full_width' );
      function force_full_width($bool) {
          return ( ! is_404() && ! is_search() ) ? true : $bool ;
      }
      /pre>
  • redpete

    Any chance you could update this article (i.e. provide the new snippet) for post 3.1 installations? I’m afraid custom hooks are a bit over my head. Is it possible to setup a different sliders: one for the 404 and another for the search? Thanks.

    • Nicolas Post author

      Hi redpete,
      Yes you can select one of the conditions used in the example to achive this. is_404() for example.
      If you are not familiar with Php and / or WordPress coding, you’ll want to start by the basics.

      Hope this helps: !

    • Marouane

      I’m not an advanced user and I hope experts would correct me if I’m wrong. But something like this should work:

  • Marouane

    Thank you very much! But is there any way to put a personlized picture instead of the slider please in the 404 and search pages?
    Thank you!

Comments are closed.