Filter link to existing content suggestion

How can i filter the link given in "link to existing content".

Eg:

As in the above image. I just want WSP BANNER TO BE SHOWN.

where WSP BANNER & CALENDAR are custom POST types

Any help will be appreciable.

-
So you want to filter the list? –  Rutwick Gangurde Jun 21 '12 at 6:53

Currently there are no ready filters available for this purpose. A ticket has been posted for the request.Lets hope we get one soon.

Instead of hardcoding your custom post types its better to create a filter hook and use it

Till then you can create your own filter.

Open includes/class-wp-editor.php and make folowing changes at line no 712

$pt_names = apply_filters('custom_insert_link_suggestion_filter',array_keys($pts ));


we just added a new filter instead of getting all the public post types

function my_filter_function($allowed_post_types) { if( condition chek) { return array('page','your custom post types'); } } add_filter('custom_insert_link_suggestion_filter','my_filter_function',10,1);  - I wrote a plugin for that. It is not in the plugins repository yet, you can download it here: http://basics09.de/download/b09.link-to-existing-content.zip Install it and then put this filter in your functions.php: add_filter("link_to_existing_content_post_types", "my_link_to_existing_content_post_types"); function my_link_to_existing_content_post_types($post_types) {
$post_types = array("post", "page"); return$post_types;
}


This plugin also has the functionality to replace internal links with shortcodes. If you don't want to use this, deactivate it like this:

add_filter("link_to_existing_content_use_shortcode", "disable_link_to_existing_content_shortcode");
return false;
}


Hope this will be useful for you!

-

if it's very very urgent, you may be want to edit class-wp-editor line 711 to

\$pts = get_post_types( array( 'name' => 'your_post_type','public' => true ), 'objects' );


, otherwise leave AS IS

-
I would highly suggest not to edit the core files, unless it can save your job ;) –  Rutwick Gangurde Jun 21 '12 at 7:17
as I said, if very very urgent :D –  Gembel Intelek Jun 21 '12 at 7:21
Yep correct! :D –  Rutwick Gangurde Jun 21 '12 at 7:26
Thanks for your answer and comments. Ya its clients requirement. –  Sujeet Jun 21 '12 at 9:03

Check the file class-wp-editor.php, line no. 742 onwards. The list doesn't have any filters applied to it. So I guess you can't change it!

More, in the same file, line no. 689, the function wp_link_query is called via an AJAX request for getting this list, it too doesn't have any filters to change the post types!

Hence, you have to live with it! ;)

-