Skip to Content

internal_suggestions()

Determine page suggestions on 404 pages.

PHP June 11, 2017

Usage

This function runs automatically, so it is not called manually. Is this incorrect?

Additional Notes

This function uses context clues from the requested URL to attempt to make suggestions for pages.

Source File

Located in /libs/Functions.php on line 2598.

No Hooks

This function does not have any filters or actions available. Request one?
PHP
    public function internal_suggestions(){
        if ( is_404() ){
            $this->ga_send_exception('(PHP) 404 Error for requested URL: ' . $this->url_components()); //Track 404 error pages as exceptions in Google Analytics

            $this->slug_keywords = array_filter(explode('/', $this->url_components('filepath')));
            $this->slug_keywords = end($this->slug_keywords);

            //Query the DB with clues from the requested URL
            $this->error_query = new WP_Query(array('post_status' => 'publish', 'posts_per_page' => 4, 's' => str_replace('-', ' ', $this->slug_keywords)));
            if ( function_exists('relevanssi_do_query') ){
                relevanssi_do_query($this->error_query);
            }

            //Check for an exact match
            if ( !empty($this->error_query->posts) && $this->slug_keywords === $this->error_query->posts[0]->post_name ){
                $this->error_404_exact_match = $this->error_query->posts[0];
            }
        }
    }

Override

This function can not be short-circuited with an override filter. Request one?