Guest User

R ALM

a guest
Jul 21st, 2024
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. function my_alm_query_args_relevanssi($args){
  2. $args = apply_filters('alm_relevanssi', $args);
  3. return $args;
  4. }
  5. add_filter( 'alm_query_args_relevanssi', 'my_alm_query_args_relevanssi');
  6.  
  7.  
  8. function custom_relevanssi_alm_shortcode() {
  9. // Check for the 'search' query parameter
  10. $term = (isset($_GET['s'])) ? $_GET['s'] : '';
  11. error_log('Search Term: ' . $term); // Log for debugging
  12.  
  13. ob_start();
  14. ?>
  15. <div id="container">
  16. <?php
  17. // Echo the Ajax Load More shortcode with the search term
  18. echo do_shortcode('[ajax_load_more
  19. id="relevanssi"
  20. target="articles"
  21. filters="true"
  22. search="'. $term .'"
  23. post_type="post"
  24. posts_per_page="8"
  25. scroll_distance="200"
  26. css_classes="tad-feed"
  27. no_results_text="<div class=\'no-results\'>Sorry, nothing found in this query</div>"]');
  28. ?>
  29. </div>
  30. <?php
  31. return ob_get_clean();
  32. }
  33. add_shortcode('custom_relevanssi_alm', 'custom_relevanssi_alm_shortcode');
  34.  
  35.  
  36. // This returns the post in question
  37.  
  38. function test_meta_query_footer() {
  39. $search_term = isset($_GET['search']) ? sanitize_text_field($_GET['search']) : '';
  40. if ($search_term) {
  41. $query = new WP_Query(array(
  42. 'post_type' => 'post',
  43. 'posts_per_page' => -1,
  44. 'meta_query' => array(
  45. array(
  46. 'key' => 'full_source_article', // Custom field key
  47. 'value' => $search_term,
  48. 'compare' => 'LIKE',
  49. ),
  50. ),
  51. ));
  52. echo '<pre>Meta Query Results: ' . print_r($query->posts, true) . '</pre>';
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment