Forums Forums Search Search Results for 'sf_current_query'

Viewing 10 results - 301 through 310 (of 318 total)
  • Author
    Search Results
  • #39701

    Anonymous
    Inactive

    Hi!
    Sorry for my late reply but I had to complete another project..
    If I do a var_dump I get the following:
    array(2) { [“authors”]=> array(5) { [“name”]=> string(7) “Authors” [“singular_name”]=> string(6) “Author” [“all_items_label”]=> string(11) “All Authors” [“type”]=> string(9) “post_type” [“active_terms”]=> array(1) { [0]=> array(3) { [“id”]=> int(39) [“name”]=> string(7) “Agenzie” [“value”]=> string(7) “agenzie” } } } [“_sf_post_date”]=> array(1) { [“active_terms”]=> array(2) { [0]=> array(1) { [“value”]=> string(8) “01032016” } [1]=> array(1) { [“value”]=> string(8) “16032016” } } } }

    In my form I have Authors (in this example value for that is “Agenzie”) and Post Date range fields.
    I am not expert in PHP…can you help me to get the authors and post date range?
    As $sf_current_query->get_field_string(“authors”) does not work.

    Thanks

    #37243

    Anonymous
    Inactive

    Hi, How would I display the sort order in a way similar to displaying categories or tags? Here’s the code I’m using, but only _sft_category and _sft_school display on my page.

    $args = array(
    	"str" => '<strong>%1$s</strong>: %2$s',
    	"show_all_if_empty" => false
    	//"field_delim" => '<hr />'
    	
    );
    echo $sf_current_query->get_fields_html(array("_sft_category", "_sft_school", "sort_order"), $args);

    Here’s a link to the test page:
    http://staging.cudenvertoday.org/articles

    Thanks!

    #35604

    Ross
    Keymaster

    what happens if you var_dump the array:

    <?php
    //Get a single fields values using labels
    //replace 1526 with the ID of your search form
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(147)->current_query();
    var_dump($sf_current_query->get_array());
    ?>

    CAn you paste the output here?

    Thanks

    #34998

    Anonymous
    Inactive

    Website is actually offline.

    I just put in page template:
    <?php
    //Get a single fields values using labels
    //replace 1526 with the ID of your search form
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(147)->current_query();
    echo $sf_current_query->get_field_string(“_sfm_xxx”);

    ?>

    and Its echo nothing. I’m using ACF fileds

    #34979

    Anonymous
    Inactive

    Im trying something like and its not working

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

    ?>

    Url looks like this:
    http://www.xxx.com/?_sfm_xxx&#8230;

    #34656

    Ross
    Keymaster

    Hi Scott

    To answer your questions:

    1) To get data from the current search you can use:
    http://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/

    So, from that link, the code would be

    <?php
    	//Get the search term
    	//replace '1526' with the ID of your search form
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(1526)->current_query();
    	echo $sf_current_query->get_search_term();
    ?>

    2) Which display method are you using? If you are using archive then it sounds like you have set your template up wrong (a little). This really depends on your theme, so go into your theme and take a look at other template files such as archive.php or search.php.

    Usually you should at least be starting with a get_header() and finishing with a get_footer() – but this is really theme dependent – https://codex.wordpress.org/Include_Tags

    Thanks

    #31935

    Anonymous
    Inactive

    So I’ve been trying to pull the field name from the Active Query Object, but I’m not able to pull any of custom fields, just categories.

    I’m able to get _sft_credit_card_category, but not the post_meta fields of _sfm_issuer and _sfm_credit_quality.

    
    <?php
    //grab the active query from our search form
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(615)->current_query();
    var_dump($sf_current_query->get_array());
    
    echo $sf_current_query->get_field_string("_sft_credit_card_category");
    echo $sf_current_query->get_field_string("_sfm_issuer");
    echo $sf_current_query->get_field_string("_sfm_credit_quality");
    ?>
    
    #31706

    Ross
    Keymaster

    Hi Stephen

    The active query class is not currently too well documented (as its just been created its subject to change a little) but you can certainly change the output of this field.

    Please take a look at this example:

    $args = array(
    	"str" 				=> '<strong>%1$s</strong>: %2$s',
    	"field_delim" 			=> '<hr />'
    	
    );
    echo $sf_current_query->get_fields_html(array("_sft_category", "_sft_post_tag"), $args);

    You can see str variable is the format output of html for each field, in the example above I’ve added <strong> tags around the name

    The next is field_delim – this is what is used to join the strings for each field – default is <br /> but you can change this to anything.

    I think with these two arguments there should be no issues with formatting the way you want.

    Thanks

    #31297

    Anonymous
    Inactive

    I’m trying to output the filtered data using your instructions on the Accessing the Search Data page (http://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/). However, the outputted field names and respective data are not wrapped in any sort of html tag.

    I would like the output to look something like this:

    <div class=”filterdata”>
    <div class=”fieldname”>Categories:</div>
    <div class=”fielddata”>Community<br/>Arts</div>
    </div>

    Is that possible by manipulating the sf_current_query?

    #30637

    Anonymous
    Inactive

    Just to be clear. The code below:

    <?php

    $sf_current_query = $searchandfilter->get(14458)->current_query();
    echo $sf_current_query->get_field_string(“_sft_category”);

    ?>

    Results: Categories: All Categories

    It doesn’t display the category that the post is assigned to when using the code:

    Categorized in: <?php the_category(); ?>

Viewing 10 results - 301 through 310 (of 318 total)