I would also like to know how to customize the 404 page.
mm @marouane87 you invented “tc_show_image” and “tc_image_name_id” that’s why nothing happens.
Nicolas’ snippet was to show a slider in that page, create a slider and use that snippet.
Do you want something like:
[slider]
[missing page alert]
[search]
?
I thought maybe it was the same, my mistake π !
No need for slider, just:
[missing page alert] (which is the personalized picture)
[Search]
Thank you very much!
Try this then,
add_filter('tc_404_content', 'my_404_content');
function my_404_content(){
$image_url = 'REPLACE THIS WITH YOUR IMAGE URL';
return sprintf('<img alt="Not Found" class="404-img" src="%1s">%2$s',
$image_url,
get_search_form( $echo=false)
);
}
Thank you very much! One final request please, is it possible to display the same when a search request has no result?
Thank you again π !
You’re welcome.
Just add also this to your child-theme functions.php
add_filter('tc_no_result_content', 'my_404_content');
This will point to the same function my_404_content.
Thank you very much!
In case someone wants to delete “No Search Results for : nothing” and the glass icone (like me), just add
add_filter('tc_search_results_header_content', 'my_no_result');
function my_no_result(){
return;
(Yes, I’m learning to write small functions π !)
Oh great you took a look at the hooks api π
( You’re on the right track… so don’t delude me π )
Unfortunately the hook tc_no_results_content_icon, as the name suggests, is about an icon you already don’t display because we get rid of the original content with the code I posted above.
You’re interested about some Headings filters like:
add_filter('tc_search_results_header_content', 'change_search_title');
function change_search_title($header){
/* with this if you change the search title when there are no results */
if ( is_search() && ! have_posts() ){
$new_title= '<h1>My New No result title</h1>';
return preg_replace('|<h1.*?</h1>|', $new_title,$header);
}
return $header;
}
Hey, you edited that message a bunch of time, making my reply useless π
I’m glad you’re learning π
I’m sorry about that, I was trying after I posted the question, so I updated my last message depending on my progress π !