Z
Z
zzmaster2020-05-23 12:50:50
WordPress
zzmaster, 2020-05-23 12:50:50

How to remove Nothing found on a custom Wordpress page?

I want to make a page with a specific url on which a message will be displayed.

add_action( 'template_redirect', function() {
    global $wp_query;
    if ($_SERVER['REQUEST_URI']=='/lalafa') {
        if ($wp_query->is_404) {
            $wp_query->is_404 = false;
        }
        header("HTTP/1.1 200 OK");
        wc_add_notice( __('Thank you.', 'my-space'));
    }
});


Order - the message is displayed, but at the bottom, after it:

Nothing Found
It seems we can’t find what you’re looking for. Perhaps searching can help.
<<и здесь форма поиска>>


How to get rid of it? Maybe there is another way to do what I want?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WP Panda, 2020-05-23
@zzmaster

1) endpoints are used for this.
2) ok, you hung up on 'template_redirect' and what template are you slipping? You have the same 404.php and it remains.

Z
zzmaster, 2020-05-25
@zzmaster

add_action( 'template_include',function($template) {
  if ($_SERVER['REQUEST_URI']=='/lalafa')
     return __DIR__.'/thank-you.php';
return $template;
});

thank -you.php
<?php get_header() ?>
<div style="display:flex; align-items: center; justify-content: center; min-height:400px; ">
<h3 style="text-align: center;">Thank you man</h3> 
</div>
<?php get_footer() ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question