Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Issue with WordPress Default Media Attachment PDF Search Functionality via WP AJAX #4004

Open
1 task done
mahesh-spinx opened this issue Nov 14, 2024 · 2 comments
Open
1 task done
Labels
bug Something isn't working reporter feedback stale

Comments

@mahesh-spinx
Copy link

mahesh-spinx commented Nov 14, 2024

Describe the bug

I am experiencing an issue when performing keyword searches via AJAX in the default WordPress media attachment PDFs. Specifically, when using the WP_Query with ElasticPress integration, the search results do not appear in the AJAX callback. However, the same query works correctly when the page is reloaded. This is specific for attachment post

Could you please assist in resolving this issue or provide guidance on how to troubleshoot the AJAX search functionality with ElasticPress?

I added ajax function code for your reference.

Thank you for your support.

Steps to Reproduce

function attach_search_datatable() {	
        add_filter( 'ep_ajax_wp_query_integration', '__return_true' );
        add_filter( 'ep_enable_do_weighting', '__return_true' );
	 
	$args = array(
	'post_type'      => 'attachment',
	'posts_per_page' => 10,        
	's'               => 'document', 
	'ep_integrate'    => true        		
	);
	
	$query = new WP_Query( $args );
	if ( $query->have_posts() ) :
		while ( $query->have_posts() ) : $query->the_post();
			echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a><br>';
		endwhile;
		

		wp_reset_postdata();
	else :
		echo 'No PDFs found.';
	endif;
	
	wp_die();
}
add_action('wp_ajax_nopriv_attach_search_datatable', 'attach_search_datatable');
add_action('wp_ajax_attach_search_datatable', 'attach_search_datatable');

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress and ElasticPress information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@mahesh-spinx mahesh-spinx added the bug Something isn't working label Nov 14, 2024
@felipeelia
Copy link
Member

The code looks right, @mahesh-spinx, I'd only check the post status. You can follow this article to troubleshoot AJAX requests.

Copy link

It has been 3 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 3 days, but if you have more information to add then please comment and the issue will stay open.

@github-actions github-actions bot added the stale label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reporter feedback stale
Projects
None yet
Development

No branches or pull requests

2 participants