Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search Search Results for 'sf_edit_query_args'

Viewing 10 results - 81 through 90 (of 205 total)
  • Author
    Search Results
  • #196685

    Trevor
    Moderator

    If you are trying to use the sf_edit_query_args to set a default value (and I agree it looks like this is an ideal case use for this filter), it does not work on initial page load (from my previous testing). This will not be addressed (in a different way) until V3.

    #196621

    James Piper
    Participant
    This reply has been marked as private.
    #195017

    Jessica Cassity
    Participant

    I’m having problems filtering sf_edit_query_args with the post__in query arg. Here’s a quick prototype that I have:

    
    add_filter( 'sf_edit_query_args', function( $query_args, $sfid ) {
        if ( 20205 === $sfid ) {
            $query_args['post__in'] = array( 20696, 20694, 20612 );
        }
    
        return $query_args;
    }, 20, 2 );
    

    I double-checked that 20205 is the id of the search&filter form and that 20696, 20694, 20612 are actual custom post type ids. The form works as it should with the usual search&filter search field, custom post type filters, tag dropdowns, etc. But I’m not able to filter it programmatically with the provided post ids (however, it works correctly with a provided custom post type – $query_args['post_type'] = 'custom';). It simply returns no results. Is the post__in query arg not supported?

    Thanks!


    Damon Tribble
    Participant

    Take a look at this page. http://powerschoolnew.staging.wpengine.com/resources/?post_types=whitepaper

    I have 7 sticky posts in this post type. You can find them in the HTML with class=”resource-block featured”. When I first load the URL above, only 3 of the sticky posts appear in the first set of results (I wrap them in a carousel using jQuery). As I scroll, the other sticky posts appear(they will be 50% wide. I then move them to the top with jQuery.

    Why aren’t my sticky posts ALL appearing first before all non-sticky posts? I tried deliberately setting ignore_sticky_posts to false using sf_edit_query_args but this made no difference.

    Thanks for any help you can offer.

    #191286

    In reply to: modify $query


    Anja Faeßer
    Participant

    Now I thought about the problem again and looked at the documentation. I found the following: “Edit Query Arguments”.

    Then I tried the following:

    function filter_function_name( $query_args, $sfid ) {
    
    	if($sfid==163) {
    
    		$query_args['tax_query'] = array(
    			'relation' => 'OR',
    			array(
    				'taxonomy' => 'region',
    				'field'    => 'slug',
    				'terms'    => array( 'Österreich' ),
    			),
    		);
    	}
    	
    	return $query_args;
    }
    add_filter( 'sf_edit_query_args', 'filter_function_name', 20, 2 );

    Unfortunately this works exactly the other way round to what I want.
    Now only articles with the tag Austria are displayed.

    Is there any way to modify it to work the way I think it should?

    #189780

    Lisa Kriga
    Participant

    Depending on which values are chosen in the inputs for rw (22-26) and tc (1-3) the corresponding ws and fw-value is used in the sliders. That is, if I choose 22 as rw and 1 as tc then the values in those meta boxes for ws and fw are compared to the data chosen in the rangers (ws-22-1 and rw-22-1), so I basically would need a conditional range slider which is not available.

    The code above is used with “sf_edit_query_args”. (I have asdo tried using “sf_results_url” as mentioned in the first text, but that didn’t work since it only gets me the base-url.)

    But if this is not the way to use the filter, how is it suppose to work? I thought the filter “sf_edit_query_args” would alter the query for the search, what does it do then? Just in case that will give me some new idea on how to advance.

    Otherwise I’ll just have to figure out a way to update the search query ’cause this is an important feature of this filter.

    #188858

    Ross
    Keymaster
    This reply has been marked as private.
    #188835

    Ross
    Keymaster
    This reply has been marked as private.
    #188497

    Eduardo Scherer
    Participant
    This reply has been marked as private.
    #188232

    I’m using the code bellow to hide posts that are older than the current date. It’s working on the default results but it’s not working on the filter(dropdown).

    Is there a way to exclude old posts from showing on the filter(Search Form UI) too?

    Thanks

    add_filter( ‘sf_edit_query_args’, ‘kp_exclude_old_post’, 100, 2 );
    function kp_exclude_old_post( $query ) {

    $time_ago = date(‘Y-m-d’, strtotime(‘-1 day’));

    $query[‘meta_query’] = array(
    array(
    ‘key’ => ‘acfDia’,
    ‘value’ => $time_ago,
    ‘compare’ => ‘>=’,
    ‘type’ => ‘DATE’
    )
    );

    return $query;
    }

Viewing 10 results - 81 through 90 (of 205 total)