Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Elementor Archive Posts Nothing Found Message Override › Reply To: Elementor Archive Posts Nothing Found Message Override
I was successful in being able to get the correct No Results message now that I’ve switched over to the Posts block.
Using the Elementor Custom Query Filter documentation as a guide, below is what I’ve tested. I’ve been able to return a specific post on the initial query (when the page initially loads), but I’m wanting to return the specific post if they type in the search a term that returns no results.
/*Attempt return specific post if no posts found in query*/
add_action('elementor/query/fellow-donations', function($query){
if(!$query->have_posts()){
$query->set('post__in', array(810)); //ends up returning the 1 post even if there are posts.
//only returns this for the initial page load, after someone attempts to search and then backspaces everything shows
}
});
I’m wondering if it may not be working due to another issue as well. When the page initially loads (without this script) my post 810, which is named “Unlisted Professor” is there, but if someone searches and then back spaces to have nothing in the search bar again when all of the elements load back in the “Unlisted Professor” post is no longer listed. I am not excluding it within the Advanced Options.
Thanks again for your help!