Change "Nothing found" view.

This topic contains 2 replies, has 3 voices, and was last updated by  Kiran 5 years, 8 months ago.

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

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #476354

    Hi there.
    I have a little tricky question:
    I would like to redirect a user in case he gets a reult with “no listings in this area” to an other page.
    Is there any chance to do this also coding things are welcome, just put me in the right correction.
    Thank you very much in advance!

    #476361

    Kor
    Moderator
    Post count: 16516

    Hi Oliver Koenig,

    Thanks for your post. It would require customization to achieve what you needed there. But I’ll forward this to a developer for a second opinion.

    Thanks!

    #476425

    Kiran
    Moderator
    Post count: 7069

    Hello Oliver,

    I believe you are using GeoDirectory v2.

    Please use following code snippet to redirect page on no posts founds.

    
    
    /**
     * Redirect to page on no posts founds.
     */
    function gd_snippet_190326_redirect_no_posts() {
    	global $wp_query;
    
    	if ( ! empty( $wp_query ) && ! have_posts() && ( geodir_is_page( 'archive' ) || geodir_is_page( 'post_type' ) || geodir_is_page( 'search' ) ) ) {
    		$redirect_url = home_url(); // Redirect url. Ex: 'https://www.mysite.com/'
    
    		wp_safe_redirect( $redirect_url );
    		exit;
    	}
    }
    add_action( 'template_redirect', 'gd_snippet_190326_redirect_no_posts', 999 );

    Kiran

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

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

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount