• Hi. I have a custom search template for my custom post type. i just want to include that in my search.php. The idea is to display post thumbnail in 4 column grid layout. So i added this just after loop begins

    if(wp_verify_nonce($_GET['s'], ‘awqsfsearch’) ){
    include(TEMPLATEPATH . '/search-phones.php');
    }
    else {
    include(TEMPLATEPATH . '/search.php');

    but when i search, it display default search result layout along with 4-5 lines of codes. I think i am doing somewhere wrong as i am not a coder. Could you please figure it out?

    https://www.ads-software.com/extend/plugins/advance-wp-query-search-filter/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TC.K

    (@wp_dummy)

    Try use this:

    $options = get_post_meta($_GET['formid'], 'awqsf-relbool', true);
    if(isset($_GET['wqsfsubmit']) && $_GET['wqsfsubmit']==$options[0]['button']){
    include(TEMPLATEPATH . '/search-phones.php');
    }else{
    include(TEMPLATEPATH . '/search.php');
    }
    Thread Starter sanshr

    (@sanshr)

    Updated with this but no success. Here is my search.php and i added this in line 70. May be some syntax irregularities causing the codes showing along with results. the URL also looks quite weird. Like this:
    https://www.cellularism.com/?s=8db0521a46&formid=2298&taxo%5B0%5D%5Bname%5D=phone_device_type&taxo%5B0%5D%5Bterm%5D=smartphone&taxo%5B1%5D%5Bname%5D=phone_brand&taxo%5B1%5D%5Bterm%5D=nokia&taxo%5B2%5D%5Bname%5D=phone_weight&taxo%5B2%5D%5Bterm%5D=wqsftaxoall&taxo%5B3%5D%5Bname%5D=phone_thickness&taxo%5B3%5D%5Bterm%5D=wqsftaxoall&taxo%5B4%5D%5Bname%5D=phones_display_type&taxo%5B4%5D%5Bterm%5D=wqsftaxoall&taxo%5B5%5D%5Bname%5D=phone_display-size&taxo%5B5%5D%5Bterm%5D=wqsftaxoall&taxo%5B6%5D%5Bname%5D=phone_display_resolution&taxo%5B6%5D%5Bterm%5D=wqsftaxoall&taxo%5B7%5D%5Bname%5D=phone_pixel_density&taxo%5B7%5D%5Bterm%5D=wqsftaxoall&taxo%5B8%5D%5Bname%5D=phone_cpu_cores&taxo%5B8%5D%5Bterm%5D=wqsftaxoall&taxo%5B9%5D%5Bname%5D=phones_operating_system&taxo%5B10%5D%5Bname%5D=phone_processor_speed&taxo%5B10%5D%5Bterm%5D=wqsftaxoall&taxo%5B11%5D%5Bname%5D=phone_built_in_storage&taxo%5B11%5D%5Bterm%5D=wqsftaxoall&taxo%5B12%5D%5Bname%5D=phone_ram&taxo%5B12%5D%5Bterm%5D=wqsftaxoall&taxo%5B13%5D%5Bname%5D=phone_primary_camera&taxo%5B13%5D%5Bterm%5D=wqsftaxoall&taxo%5B14%5D%5Bname%5D=phone_secondary_camera&taxo%5B14%5D%5Bterm%5D=wqsftaxoall&taxo%5B15%5D%5Bname%5D=phones_network&taxo%5B16%5D%5Bname%5D=phones_multiple_sim&taxo%5B17%5D%5Bname%5D=phones_video_recorder&taxo%5B18%5D%5Bname%5D=phones_sensors&taxo%5B19%5D%5Bname%5D=phone_battery&taxo%5B19%5D%5Bterm%5D=wqsftaxoall&taxo%5B20%5D%5Bname%5D=phones_other-features&taxo%5B21%5D%5Bname%5D=phone_price&taxo%5B21%5D%5Bterm%5D=wqsftaxoall&cmf%5B0%5D%5Bmetakey%5D=make&cmf%5B0%5D%5Bcompare%5D=1&cmf%5B0%5D%5Bvalue%5D=wqsfcmfall&skeyword=&wqsfsubmit=Search

    Plugin Author TC.K

    (@wp_dummy)

    The link is fine.

    Try this :

    if(isset($_GET['wqsfsubmit'])){
    include(TEMPLATEPATH . '/search-phones.php');
    }else{
    include(TEMPLATEPATH . '/search.php');
    }

    If this failed again, then might be your search-phones.php problem?

    Thread Starter sanshr

    (@sanshr)

    I am really lost now. nothing gonna work. I have created even the basic search template and call it from my search.php. I think i am putting the above in wrong place. Please be specific exactly where i put this code. i added this just after :-
    <?php if (have_posts()) : while (have_posts()) : the_post(); $postcount++;

    which finally looks like

    <div class="section">
    
                    <?php _e( 'Search Results', 'made' ); ?>
    
                </div>        
    
            </div>
    
            <div class="ribbon-shadow-right">?</div>   
    
            <div class="section-arrow">?</div>
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); $postcount++;
    if(isset($_GET['wqsfsubmit'])){
    include(TEMPLATEPATH . '/search-phones.php');
    }else{
    include(TEMPLATEPATH . '/search.php');
    }
    
    $thisPostType = get_post_type(); //get post type
    			$thisReviewType = $oswcPostTypes->get_type_by_id($thisPostType); //get review type object
    			$isreview=false;
    			if($thisPostType!='post' && $thisPostType!='page' && $thisPostType!='attachment') $isreview=true; //set review variable
    			if($isreview) {
                    $icon = $thisReviewType->icon;
    				$icon_light = $thisReviewType->icon_light;
    				if($oswc_skin=="dark") $icon=$icon_light;
                    $cat = $thisReviewType->name;
                } else {
                    $cats = get_the_category();
                    $cat = $cats[0]->cat_name;
                }
    			//show rating?
    			$rating_hide = get_post_meta($post->ID, "Hide Rating", $single = true);
    			//check if this is a video post
    			$isvideo=false;
    			$video = get_post_meta($post->ID, "Video", $single = true);
    			if($video!="") $isvideo=true;
    			?>
    Plugin Author TC.K

    (@wp_dummy)

    Okay, another option.
    On top of your search.php file (before the get_header();), put this conditional check.

    <?php
    $options = get_post_meta($_GET['formid'], 'awqsf-relbool', true);
    if (isset($_GET['wqsfsubmit']) && $_GET['wqsfsubmit'] == $options[0]['button']) : get_template_part('search','custom'); return; endif; ?>

    On the search-custom.php template (or whatever you call it, by referring get_template_part(‘search’,’custom’)), you create a whole new search result template, including the get_hearder and get_footer.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to include custom search template in theme search.php’ is closed to new replies.