wpfts_se_output (Filter)

The wpfts_se_output filter in WP Fast Total Search allows developers to modify the HTML code of Smart Excerpts immediately before output on the search results page. This provides complete control over the display of excerpts, including text, links, relevance, file size, and other elements.

When to Use

  • Modifying the Styling of Smart Excerpts: You can add CSS classes, change styles, or add new HTML elements.
  • Adding or Removing Information: You can add information such as the publication date or author, or remove unnecessary elements, such as relevance or file size.
  • Complete Overriding of HTML Code: You can completely override the HTML code of Smart Excerpts.

Arguments

  • $a (array): An associative array containing the HTML code of various Smart Excerpts elements. Array keys:
    • excerpt_text: The HTML code of the excerpt text.
    • not_found_words: The HTML code of not found words.
    • score: The HTML code of the relevance score.
    • link: The HTML code of the file download link (for attachments).
  • $post (array): An array of post data.

Return Value

  • $a (array): The modified array with the HTML code of Smart Excerpts.

Example (Adding Publication Date)

add_filter('wpfts_se_output', 'add_post_date_to_excerpt', 10, 2);
function add_post_date_to_excerpt($a, $post)
{
	$date = get_the_date('', $post['ID']);
	if ($date) {
		$a['excerpt_text'] .= '<div class="wpfts-post-date">' . $date . '</div>';
	}
	return $a;
}
 
add_filter('wpfts_se_output', 'customize_download_link', 10, 2);
 
function customize_download_link($a, $post) {
 
	if ( isset($a['link']) && !empty($a['link']) ) {
 
		$a['link'] = str_replace( 
			'<a class="wpfts-download-link', 
			'<a class="wpfts-download-link my-custom-class', 
			$a['link'] 
		);
 
	}
 
	return $a;
}

Important Notes

  • The wpfts_se_output filter is called immediately before the output of the Smart Excerpts HTML code.
  • Changes made to the $a array will be reflected on the search results page.

This filter gives developers maximum control over the display of Smart Excerpts in WP Fast Total Search.