Jump to content

Strip out shortcodes in listing list view


JoshLewis

Recommended Posts

Recently wanted to have shortcodes stripped from listing list view. Based on the docs I modified it to:

/* Strip out listing list views summary shortcodes */

function list_page_replace_summary($listings, $params)
{
	foreach ($listings as & $listing)
	{
		if ( $listing['Listing']['description'] )
		{
			// Uncomment line below to show truncated description instead of summary in listing list view
			// $listing['Listing']['summary'] = $listing['Listing']['description'];
			$listing['Listing']['summary'] = strip_shortcodes($listing['Listing']['summary']);
		}
	}
 
	return $listings;
}
 
Clickfwd\Hook\Filter::add('post_get_listings_listpage_query', 'list_page_replace_summary', 10);

This allows other neat variations such as conversions and alternative data display.

Link to comment
×
×
  • Create New...