Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function my_alm_query_args_relevanssi($args){
- $args = apply_filters('alm_relevanssi', $args);
- return $args;
- }
- add_filter( 'alm_query_args_relevanssi', 'my_alm_query_args_relevanssi');
- function custom_relevanssi_alm_shortcode() {
- // Check for the 'search' query parameter
- $term = (isset($_GET['s'])) ? $_GET['s'] : '';
- error_log('Search Term: ' . $term); // Log for debugging
- ob_start();
- ?>
- <div id="container">
- <?php
- // Echo the Ajax Load More shortcode with the search term
- echo do_shortcode('[ajax_load_more
- id="relevanssi"
- target="articles"
- filters="true"
- search="'. $term .'"
- post_type="post"
- posts_per_page="8"
- scroll_distance="200"
- css_classes="tad-feed"
- no_results_text="<div class=\'no-results\'>Sorry, nothing found in this query</div>"]');
- ?>
- </div>
- <?php
- return ob_get_clean();
- }
- add_shortcode('custom_relevanssi_alm', 'custom_relevanssi_alm_shortcode');
- // This returns the post in question
- function test_meta_query_footer() {
- $search_term = isset($_GET['search']) ? sanitize_text_field($_GET['search']) : '';
- if ($search_term) {
- $query = new WP_Query(array(
- 'post_type' => 'post',
- 'posts_per_page' => -1,
- 'meta_query' => array(
- array(
- 'key' => 'full_source_article', // Custom field key
- 'value' => $search_term,
- 'compare' => 'LIKE',
- ),
- ),
- ));
- echo '<pre>Meta Query Results: ' . print_r($query->posts, true) . '</pre>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment