I would like to be able to remove a custom post type AND add attached media (PDF’s, Images, Docs, etc) to the “Link to existing content” in the Add / Edit link popup in the WYSIWYG editor.
Essentially, I’ve created a custom content type, but have way to many with the same name. So, I’d like those removed from the search results.
In addition, I have a bunch of PDF’s I’ve uploaded and would like to easily be able to link to those.
Anyone ever accomplished this, know a plugin or have the hook to modify it?
Old question but I found an answer at Here by Simon Hampel at the bottom. Cool filter, but I coulnd’t find a whole lot of documentation on it so I’m not 100% sure everything it’s connected to. One thing I do know is it’s used to pull the links on ‘Link to existing content’. Put this in your functions.php
file:
function custom_wp_link_query_args($query)
{
$pt_new = array();
$exclude_types = array('exclude_post_types_here');
foreach ($query['post_type'] as $pt)
{
if (in_array($pt, $exclude_types)) continue;
$pt_new[] = $pt;
}
$query['post_type'] = $pt_new;
return $query;
}
add_filter('wp_link_query_args', 'custom_wp_link_query_args');