Forums Forums Search & Filter Pro Search Term not showing on Custom Archive Page

Viewing 10 posts - 1 through 10 (of 11 total)
  • Anonymous
    #233987

    Hello,

    I have a custom archive page that I’ve setup names test-search.php. When I run a search, I am taken to the template page and see my results, however I’m unable to get the Search Term/Query Term to display on the Template. It shows in the title bar of the page as Search Results for “” Additionally, I have a Breadcrumbs Bar that should show the page_title and it just shows as blank or it displays the first search results page name instead of the actual search term.

    My Code is below:

    <?php get_header(); ?>
    <?php
    $falcons_option_data =get_option('falcons_option_data'); 
    wp_enqueue_style('iv_directories-style-110', falcons_CSS . 'listing_style_1.css');
    wp_enqueue_style('single-cpt1-style-2', falcons_CSS.'single-cpt1.css', array(), $ver = false, $media = 'all');
    ?>
    
    	
    	 <?php
    		$top_breadcrumb_image= falcons_IMAGE."banner-breadcrumb.jpg";
            if(isset($falcons_option_data['falcons-banner-breadcrumb']['url']) AND $falcons_option_data['falcons-banner-breadcrumb']['url']!=""):
    			$top_breadcrumb_image=esc_url($falcons_option_data['falcons-banner-breadcrumb']['url']);
             endif;
             
             $falcons_breadcrumb_value='1';
             if(isset($falcons_option_data['falcons-breadcrumb']) AND $falcons_option_data['falcons-breadcrumb']!=""):
    			$falcons_breadcrumb_value=$falcons_option_data['falcons-breadcrumb'];
             endif;
             
             
             if($falcons_breadcrumb_value=='1'){ 
    		?>
    		 <div class="breadcrumb-content">
    			<img   src="<?php echo $top_breadcrumb_image;?>" alt="<?php esc_html_e( 'banner', 'falcons' ); ?>">
    			<div class="container">
    				<h3> <?php
    					 the_title();
    					?></h3>
    				<h4 class="citystate"><?php the_field('city'); ?>, <?php the_field('country'); ?>	</h4>			
    			</div>
    		</div>	
    		<?php
    			}
    		?>	
    
    <div class=" ">
    	
    
    <div class="searchfilterform">
    <?php  echo do_shortcode('[searchandfilter slug="testing"]'); ?>
    </div>
    
    <div class="blog-content ">
    <div class="container">
    <div class="row">
    	  <?php
    
    $wp_iv_directories_URLPATH=wp_iv_directories_URLPATH;
    
    wp_enqueue_style('iv_directories-style-71', wp_iv_directories_URLPATH . 'assets/cube/css/cubeportfolio.css');
    wp_enqueue_style('single-cpt1-style84', falcons_CSS.'single-cpt1.css', array(), $ver = false, $media = 'all');
    	?>
    	
    <div class="col-md-12">
    <?php if(have_posts()) : ?>
    <?php $args = array( 'post_type' => 'providers', 'posts_per_page' => 10); $args['search_filter_id'] = 1902;
    $loop = new WP_Query( $args ); 
     while ( $loop->have_posts() ) : $loop->the_post(); ?>
    	
    <div class="col-sm-4 cbp-item"><div class="cbp-item-wrapper"><div class="cbp-caption-defaultWrap">
    <div class="image-container">
     <?php if ( has_post_thumbnail() ) {
    $image_id =  get_post_thumbnail_id( get_the_ID() );
    $large_image = wp_get_attachment_url( $image_id ,'full'); 
    $resize = falcons_aq_resize( $large_image, true );
    ?>
    <a href="<?php the_permalink(); ?>"> <img src="<?php echo esc_url($resize); ?>" alt="<?php esc_html_e( 'image', 'falcons' ); ?>"></a>
    </div>
    <?php } ?>
    </div>
    <div class="cbp-caption"> 
    <h5><a class="cbp-l-grid-team-name"  href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>		
    <?php if (get_post_meta($id,'city','country')) { ?>
    <?php echo get_post_meta($id,'city',true);?>, <?php echo get_post_meta($id,'country',true);?>
    <?php } ?>				
    </div></div></div>
    <?php endwhile; else : ?>
    
    <h2><?php esc_html_e('Sorry, No Providers Found', 'falcons'); ?></h2> 
    <?php endif; ?>
    	</article>
    <?php if(function_exists('wp_pagination')) wp_pagination(); ?>
    <?php //wp_pagination(); ?>
    	</div></div></div>
    <?php get_footer();?>
    Anonymous
    #233988

    Additionally – Here is the link to run a search: https://heliosipdirectory.com/test/

    Trevor
    #234049

    The page title and that searched for part are both from the theme template, and not from our plugin. The template looks like it is a modified search.php or archive.php template that are only ever designed to display the search string, whereas you filter is far more complex.

    You may need to refer to the theme authors as to how to alter/set the page title. WordPress does have some functions also to do this, but whether they would work would depend on the theme in use.

    To fetch the search terms, the https://searchandfilter.com/documentation/accessing-search-data/ guide is basic but you can extend the idea to grab lots of other data. If you have other filters, then it becomes a little more complex, but I can give you links. This thread might help you:

    https://support.searchandfilter.com/forums/topic/accessing-field-slug-on-search-results/

    … and this search will give similar threads I think:

    https://support.searchandfilter.com/forums/search/sf_current_query+get_array

    Note, if you are using Ajax refreshing of the results, any PHP needs to be inside the Ajax Container, or it will not update.

    You also look like you need some custom CSS:

    .searchandfilter > ul {
      margin-left: 0;
    }
    Anonymous
    #234105

    So i was able to use your documentation to grab the following query output: However, when i attempt to call the field _sfm_city it does not display anything. This is a Meta Key, does that matter? My attempt to display it is listed below

    
    Array
    (
        [_sft_specialties] => Array
            (
                [name] => specialties
                [singular_name] => Specialty
                [all_items_label] => All Items
                [type] => taxonomy
                [active_terms] => Array
                    (
                        [0] => Array
                            (
                                [id] => 355
                                [name] => Test Matter Type
                                [value] => test-matter-type
                                [count] => 1
                            )
    
                    )
    
            )
    
        [_sft_providers-category] => Array
            (
                [name] => Categories
                [singular_name] => Categories
                [all_items_label] => Categories
                [type] => taxonomy
                [active_terms] => Array
                    (
                        [0] => Array
                            (
                                [id] => 68
                                [name] => Patent Search
                                [value] => patent-search
                                [count] => 1
                            )
    
                    )
    
            )
    
        [_sft_operatingcountries] => Array
            (
                [name] => Operation Countries
                [singular_name] => Operating Countries
                [all_items_label] => All Operating Countries
                [type] => taxonomy
                [active_terms] => Array
                    (
                        [0] => Array
                            (
                                [id] => 145
                                [name] => Denmark
                                [value] => denmark
                                [count] => 1
                            )
    
                    )
    
            )
    
        [_sfm_city] => Array
            (
                [name] => 
                [singular_name] => 
                [all_items_label] => 
                [type] => post_meta
                [active_terms] => Array
                    (
                        [0] => Array
                            (
                                [name] => HARARE
                                [value] => HARARE
                            )
    
                    )
    
            )
    
    )

    `<?php
    //Get a single fields values using labels
    //replace 1526 with the ID of your search form
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1902)->current_query();
    echo $sf_current_query->get_field_string(“_sft_city”);

    ?>

    Trevor
    #234116

    If you use this code you would get the whole array:

    <?php
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1902)->current_query()->get_array();
    echo '<pre>',print_r($sf_current_query,true),'</pre>';
    ?>

    Then you can see what each is called and contains.

    Anonymous
    #234128

    It really doesn’t give me anything different then what i see above.

    It shows what I queried but I simply need to display the Name of the City…when i attempt to use the first query i showed above to show _sfm_city it doesn’t display anything. How do i get the name of the city to display:

     [_sfm_city] => Array
            (
                [name] => 
                [singular_name] => 
                [all_items_label] => 
                [type] => post_meta
                [active_terms] => Array
                    (
                        [0] => Array
                            (
                                [name] => Caracas
                                [value] => Caracas
                            )
    
                    )
    
            )
    
    )
    <?php
    	//Get a single fields values using labels
    	//replace <code>1526</code> with the ID of your search form
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(1902)->current_query();
    	echo $sf_current_query->get_field_string("_sft_city");
    	
    ?>
    Trevor
    #234130

    In this case Caracas?

    Anonymous
    #234132

    this specific search was Caracas, yes.

    Trevor
    #234134

    So, that would be:

    echo $sf_current_query["_sfm_city"]["active_terms"][0]["value"];

    I think.

    Anonymous
    #234157

    Thank You, that worked.

Viewing 10 posts - 1 through 10 (of 11 total)