Results 1 to 3 of 3

Thread: Redirecting users to a category page instead of a search results page

  1. #1
    Thread Starter
    jeanmich's Avatar
    Join Date
    Apr 2014
    Location
    France
    Posts
    74
    Thanks
    8
    Thanked 10 Times in 9 Posts

    Redirecting users to a category page instead of a search results page

    Hi,

    I noticed visitors tend to use the search bar to reach a category much more often than they use the navigation menu, leaving the search field empty, choosing a category and then clicking Search, and I was wondering if there would be a way to redirect them to the actual category instead of displaying a results page...

    The idea would be to redirect them whenever the search field is empty and a category is selected. I started working on it but I am stuck when it comes to redirection. In file search.php, here is what I did around line 30:

    Code:
    <?php 
    						    $catid = get_query_var('scat');
    						    if ( $searchTxt = '*' && ! empty( $catid ) ) {
    						    
    						    CODE FOR REDIRECTION
    						    
    						    } else {
    						    ?>
    						    <h1 class="single dotted"><?php printf( __( 'Search for \'%1$s\' returned %2$s results', APP_TD ), $searchTxt, $wp_query->found_posts );}?></h1>
    Any idea what code I could use to redirect users based on the catid?

    Alternatively, would it be possible to redirect them using a 302 or 307 redirect without affecting SEO? I already have a plugin installed that can handle this.

    Thanks for your input!

  2. #2
    samcy's Avatar
    Join Date
    Mar 2012
    Location
    Germany
    Posts
    12,098
    Thanks
    121
    Thanked 1,756 Times in 1,442 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Rolf Hassel (Samcy)

  3. #3
    Thread Starter
    jeanmich's Avatar
    Join Date
    Apr 2014
    Location
    France
    Posts
    74
    Thanks
    8
    Thanked 10 Times in 9 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: May 21st, 2014, 03:50 AM
  2. Dimitris Listing Category Page: No Results
    By mergeloew in forum Report Vantage Bugs (Legacy)
    Replies: 7
    Last Post: January 15th, 2014, 11:54 AM
  3. Vantage Blog Page Redirecting to Home Page
    By red20me in forum Vantage General Discussion (Legacy)
    Replies: 0
    Last Post: November 22nd, 2013, 05:57 AM
  4. Blank page on search results by category
    By gibbere in forum Report ClassiPress Bugs
    Replies: 2
    Last Post: April 7th, 2011, 10:23 AM