certainlyakey
7/23/2014 - 8:20 PM

Wordpress - change post types shown in insert link modal in tinyMCE editor

Wordpress - change post types shown in insert link modal in tinyMCE editor

//Change post types queried via tinyMCE editor insert link command
add_filter('wp_link_query_args', 'custom_wp_link_query_args');
function custom_wp_link_query_args($query)
{
	$pt_new = array();
 
	$include_types = array('book'); // our list of custom post types to include from the query
 
	foreach ($include_types as $pt)
	{
		// if (in_array($pt, $exclude_types)) continue; // skip anything found in our exclude list
		$pt_new[] = $pt; // add anything else back to the list
	}
 
	$query['post_type'] = $pt_new; // replace the list with our new one
 
	return $query; // don't forget to return the $query array
}