Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Really? A down vote with no comment or suggestion? Classy. –  Troy Sep 11 '13 at 14:38
add comment

1 Answer

up vote 0 down vote accepted

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');
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.