How to get Custom Field input text value and display on search to match my acf.

Home Forums Product Support Forums Ajax Search Pro for WordPress Support How to get Custom Field input text value and display on search to match my acf.

This topic contains 4 replies, has 2 voices, and was last updated by shishirbabel shishirbabel 7 years, 11 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #8725
    shishirbabel
    shishirbabel
    Participant

    Hello,
    I am using ajax search pro plugin on this site. “http://tekzonlinenew.redfoxmailer.com/”.
    I am using custom field text box and search text box. but i am unable to get custom field value on other page. I want to add custom field for filter results when submit or category page with condition.
    For Example when i submit my postal code and autocomplete search field then on results page all posts are showing . I want to know how i get the custom fields value on my results page with search phrase.(archive page or search page). when i get this value then i can match them by my custom field on result page and get relevant results.
    waiting for your response.

    #8726
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    The custom field value is submitted to the other page via the $_POST variable, as far as I can see from the form source, it should be in the $_POST[‘options’][‘aspf1_11’][‘postcode’] array key.
    Please note, that the $_POST variable is cleared when the page is reloaded!

    Usually, if I can’t find a posted value, I use var_dump($_POST); statement, it prints out everything, that is sent through the target page.

    • This reply was modified 7 years, 11 months ago by Ernest Marcinko Ernest Marcinko. Reason: fix
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #8729
    shishirbabel
    shishirbabel
    Participant

    Hi thanks for your quick response. But I am still unable to get the value. I used $_POST[‘options’][‘aspf1_11’][‘postcode’] on my archive.php nothing display. when i used var_dump($_POST); its showing NULL. I want to get value on my themes archive page.

    You can check on this url http://tekzonlinenew.redfoxmailer.com just enter any 6 digit number in postal code and bricklayer in search box then click on find it.

    Attachments:
    You must be logged in to view attached files.
    #8732
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Well, I don’t know if that is possible at all, maybe by sending additional parameters by modifying the results url.

    The problem is, that the $_POST variable is only set on the search results page, immediately after the search. So when clicking on a result, there is no information sent. However there are filters available to modify the results link, and maybe it is possible to send additional information.

    Try adding this custom filter function to your active theme directory, into the functions.php file:

    add_filter( 'asp_results', 'asp_change_url_results', 1, 1 );
     
    function asp_change_url_results( $results ) {
      foreach ($results as $k=>$v) {
        if ( isset($_POST['options']['aspf1_11']['postcode']) )
          $results[$k]->link  .= "&postcode=" . $_POST['options']['aspf1_11']['postcode'];
      }
     
      return $results;
    }

    This will add an additional parameter to the end of each result link, which should be accessible via the $_GET[‘postcode’] variable on the results page. I’m not sure if the $_POST[‘options’][‘aspf1_11’][‘postcode’] is correct, you might have to do a var_dump($_POST) within that function to see how it looks like.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #8743
    shishirbabel
    shishirbabel
    Participant

    Hi,
    Thanks for your previous reply. Can i select the category from auto suggested keywords because they linked to category page. I want to disable link on them and select from suggestion.
    After that on enter key always work like click on search button. when enter key then page redirects to the category page and when clicked on button then page redirects to the search page.

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

You must be logged in to reply to this topic.