• Hi, when clicking one of the search results below the search bar, is there any way to propagate the searched terms to the post (through get or post or any) ?
    I’d like to do some actions when displaying the post, but I need to know the term that was searched ?
    Thanks
    Jerome

Viewing 1 replies (of 1 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi Jerome,

    I would say, that it might be possible with a custom script. This should do the trick:

    jQuery(function($){
      $('.asl_r').on('click', '.item', function(e){
        e.preventDefault();
        e.stopPropagation();
        location.href = $('a.asl_res_url').attr('href') + '?kw=' + $('input.orig').val();
      });
    });

    This should be placed into the site footer within script tags.

    Alternatively, try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    add_action('wp_footer', 'asl_footer_phrase');
    function asl_footer_phrase() {
      ?>
      <script>
      jQuery(function($){
        $('.asl_r').on('click', '.item', function(e){
          e.preventDefault();
          e.stopPropagation();
          location.href = $('a.asl_res_url').attr('href') + '?kw=' + $('input.orig').val();
        });
      });
      </script>
      <?php
    }

    It will pass the ‘kw’ query variable to the results page, containing the keyword.

Viewing 1 replies (of 1 total)
  • The topic ‘Propagate search query ?’ is closed to new replies.