Forums Forums Search & Filter Pro How to get queried url, modify URLs

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Anonymous
    #106129

    Hi guys, how can i get generated url from sf into a function?
    I need to alter a parameter, i checked here: https://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/#Modify_URLs
    but it doesn’t explain how to retrieve the sf url parameters.
    If i try to print function i get “Missing argument 1 for query_url_results()”.
    Is there a way to get queried url?

    Trevor
    #106138

    What it is that you are trying to change? The URL or a field value? If this is about dates, make sure the changes I made to ACF settings do not affect the question/answer.

    Anonymous
    #106140

    It’s quite simple, i need to create a button to take all current parameters but change one of them, a date because i need to make a “previous day” pagination.

    Trevor
    #106143

    That makes sense. The function you refer to is intended to be uses to alter the results url used to open a results page, which is not what you want.

    You want to actually fetch the current page URL, like this:

    global $wp;
    $current_url = home_url(add_query_arg(array(),$wp->request));

    And then look at that and manipulate it in PHP (so echo it first, find the string that precedes the part you want, then split the current_url string up, alter the date, and stitch it back together again).

    Anonymous
    #106161

    I’ll do a try, thank you Trevor

    Anonymous
    #106176

    in my case $current_url = home_url(add_query_arg(array(),$wp->request));
    always print root url, without any queried parameter 🙁
    why that?

    Trevor
    #106180

    I am not sure. I tried to find a WordPress method to get the URL with query string using google. Maybe read this:

    https://gist.github.com/leereamsnyder/fac3b9ccb6b99ab14f36

    One suggestion was:

    echo home_url( add_query_arg( null, null ));

    This is a more generic WordPress question, so Google is your friend.

    OR ….

    You could use the Edit Query Arguments filter to get the date.

    And in this case this thread might help:

    https://support.searchandfilter.com/forums/topic/showing-the-search-query/

Viewing 7 posts - 1 through 7 (of 7 total)