Reply To: Problems with excerpt "Read more" link on search results page

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Problems with excerpt "Read more" link on search results page Reply To: Problems with excerpt "Read more" link on search results page

#12896

Ernest Marcinko
Keymaster

Hi Beth,

The code is indeed very standard and widely used, however problems arise from a different source. Basically WordPress is not capable of displaying results from sites other than the current – as the posts are stored in separate databases and IDs will collide.

I have however found a solution which works in 99% of the cases, so whenever the search override is enabled it tries to force the correct URL if possible, for cross-site results as well. However it appears that it simply won't work with the custom code you have, and it seems like it will not, unles that code is changed a bit.

So, I have made the following change to that code:

function new_excerpt_more( $more ) { // customize excerpt on blog & search results
	global $post;
	$url = isset($post->asp_guid) ? $post->asp_guid : get_permalink(get_the_ID());
	return '… <div class="button minimal"><a class="learnmore" href="'. $url . '">' . __('Read More', 'your-text-domain') . '</a></div>';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );

The difference is that this one will try to check if the URL stored by the search in the post object still exists, and if so, then uses that. So far it looks like it's working, but please let me know if that is not the case.

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)