Search redirecting to homepage upon no findings

This topic contains 5 replies, has 3 voices, and was last updated by  Naveen Giri 4 years, 7 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #509738

    Carl Barton
    Full Member
    Post count: 45

    When an word used in the search area cannot be found it redirects to my homepage rather than saying not found etc.

    Shouldnt it be coming up with a result eg. 0 found etc and staying within the Geodirectory element of my website.

    https://www.trade-decorator.co.uk/location/

    Thankyou

    #509753

    Alex Rollin
    Moderator
    Post count: 27815

    Please share WP Admin and FTP credentials so the developers can look into it.

    It looks like any search redirects to the home page.

    #509754

    Alex Rollin
    Moderator
    Post count: 27815
    This reply has been marked as private.
    #509760

    Carl Barton
    Full Member
    Post count: 45
    This reply has been marked as private.
    #509846

    Alex Rollin
    Moderator
    Post count: 27815
    This reply has been marked as private.
    #509974

    Naveen Giri
    Moderator
    Post count: 1559

    Hi Carl,

    you have “All 404 Redirect to Homepage” plugin that redirecting it to homepage.

    please use following code snippet.

    
    add_action('wp', 'gd_patch_p404_redirect', 1);
    function gd_patch_p404_redirect(){
    	remove_action( 'wp', 'p404_redirect' );
    
    	if ( is_404() && !is_search() && empty( $_REQUEST['geodir_search'] ) )
    	{
    
    		$options= P404REDIRECT_get_my_options();
    		$link=P404REDIRECT_get_current_URL();
    		if($link == $options['p404_redirect_to'])
    		{
    			echo "<b>All 404 Redirect to Homepage</b> has detected that the target URL is invalid, this will cause an infinite loop redirection, please go to the plugin settings and correct the traget link! ";
    			exit();
    		}
    
    		if($options['p404_status']=='1' & $options['p404_redirect_to']!=''){
    			$links = P404REDIRECT_read_option_value('links',0);
    			P404REDIRECT_save_option_value('links', $links + 1);
    			P404REDIRECT_add_redirected_link(P404REDIRECT_get_current_URL());
    			header ('HTTP/1.1 301 Moved Permanently');
    			header ("Location: " . $options['p404_redirect_to']);
    			exit();
    		}
    	}
    }

    Thanks

Viewing 6 posts - 1 through 6 (of 6 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket