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.

dpolonsky

Forum Replies Created

Viewing 10 posts - 1 through 10 (of 21 total)
  • dpolonsky in reply to:
    Set "selected" when using the sf_input_object_pre hook to alter select field?
    #215875

    Ok, thank you for confirming. I think I’ll just add a snippet of JS where I can pass a value from the PHP and if the post type is what I’m looking for, I can set the value with JS as a “hack” for now. Since I’m not using ajax for the form and the form has to be submitted to filter results, it should work okay. Thanks!

    dpolonsky in reply to:
    Trigger search submit
    #213838

    Actually I figured out a way. Since I’m working in WordPress, most of what I need is in the query vars. So I manually re-created the url that the form generates when it filters by post type, and just ensured that I was pulling the shortcode ID, the search term that is encoded dynamically so that it wasn’t hardcoded.

    Worked like a charm without having to worry about hooks or JS or anything fancy. I added a setting on the admin so that I could add the ID of the shortcode and have it dynamically pull into the template on the shortcode call without having to hardcode that either. So it’s there as a fall back in case the shortcode ID isn’t present in the query vars.

    Here is an example of what the code looks like, in case it helps someone:

    
    $search_term        = get_search_query();
    $get_shortcode_id   = Search_Helpers::get_sf_pro_shortcode_id();
    $shortcode_id_query = isset( $wp_query->query_vars['sfid'] ) && ! empty( $wp_query->query_vars['sfid'] ) ? $wp_query->query_vars['sfid'] : $get_shortcode_id;
    $raw_search_term    = rawurlencode( $search_term );
    
    <div class="alert alert-info event">
    					<p>We've found upcoming events related to your search term "<?php echo $search_term; ?>".
    						<a href="<?php echo home_url() . '/?sfid=' . $shortcode_id_query . '&_sf_s=' . $raw_search_term . '&post_types=event'; ?>">
    							Go to related events
    							<span aria-hidden="true" class="glyphicon-chevron-right glyphicon"></span>
    						</a>
    					</p>
    				</div>
    
    dpolonsky in reply to:
    Trigger search submit
    #213834

    Yes, I need to make sure the post type is set to a specific post type before it re-submits the form.

    dpolonsky in reply to:
    Results displaying on index.php instead of search.php after first submission
    #208110

    I managed to pull the term in by using the sf_input_object_pre hook so find the search field and check if the value was empty. On my site, the only way to get to the search results page is from the header search so they should always arrive with a search term. So by getting the term from $wp->query_vars['s'], it will fill it into the shortcode form before it renders the first time on the results page.

    I’m still having some funky issues though – like the logo on my site is a link to the homepage on every page that is NOT the homepage. But since is_home is now true on the search results page despite that I’m forcing the is_search from the plugin options, I had to edit my logo so it would be a link if it was search with is_search. So far so good. Thank you for all your patience. Much appreciated.

    dpolonsky in reply to:
    Query vars and results order don't match
    #207153

    I figured it out! These posts were stickies! I don’t even have the words – spent so much time on this. Wow. I removed the sticky status on these posts and then everything was fine. Please mark this as resolved.

    dpolonsky in reply to:
    Query vars and results order don't match
    #207147

    Ok so I found the issue – or at least what’s really happening. It’s not the orderby or any query args that I set.

    The query for S&F and WP are the same at this point. I even commented out any other pre_get_posts filters I may have had elsewhere in my theme. What happens is for some reason, there are these 5 posts that get put on the top regardless of the search term/order/whatever. So I tried using the WP search with a keyword that had 7 results. I got the same 7 results with the S&F search in the order I wanted, however 5 unrelated posts were on top of them.

    If I change the search term, use the sorting field to change the order, the results change like they’re supposed to, with the exception of those 5 persistent posts on top. It’s the strangest thing – why would that happen?

    I looked up the post IDs for these 5, and they are included in the post__in arg from S&F. I’m not finding any common link between them – they’re different post types. Different categories. I checked the post meta on one to see if there was custom meta from my end, nothing out of the ordinary.

    The results count is correct too, so if there are 7 results, $wp_query->found_posts will be 7. But what displays are those 7, plus those 5 results I can’t seem to get rid of. It’s really baffling.

    dpolonsky in reply to:
    Query vars and results order don't match
    #207143

    I got the shortcode to show again – nevermind on that part. Still working with getting the post order correct. Will post again if I find any other clues. Thank you for your patience.

    dpolonsky in reply to:
    Query vars and results order don't match
    #207139

    I’ve undid the settings where I had “custom” set in my “Display Results” tab. So it’s back on archive and set to search.php how I originally had it. My PHP code is back to how I had it as well, minus any S&F hook customizations. However, now the shortcode on search.php is no longer showing the form. When I var dump it, it’s an empty string. Why would the form disappear on the search.php template after changing the “Display Results” settings to “custom” and then back to “archive”? I tried making a new form to see if that was the issue, and the shortcode still no longer outputs the form. 🙁

    dpolonsky in reply to:
    Query vars and results order don't match
    #207089

    I changed my Display Results tab settings where the method is “custom”, added in the url to my search results which is the WP default http://my-url/search, and I still get a fatal memory error.

    The only difference is I noticed my pre_get_posts function is hooked to add_filter not add_action – should I be using that instead?

    dpolonsky in reply to:
    Query vars and results order don't match
    #207085

    I commented out the function that used the sf_edit_query_args hook. Then I added the query set to my existing modify_search_results_order function that’s using pre_get_posts after all the query args I already set. For some reason it caused a fatal error regarding memory size. I thought maybe it was the syntax, so I changed it to $query->query_vars['search_filter_id'] = 493580; and that seemed to cause endless looping with constant undefined index errors.

    Am I applying it correctly?

    On my WP admin settings, I have the “Display Results” tab set where the method is “As an archive” and the template options are using a custom template, search.php. No slug set and no ajax.

    Thanks.

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