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.

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

Eg:enter image description here

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.

share|improve this question
    
So you want to filter the list? –  Rutwick Gangurde Jun 21 '12 at 6:53

4 Answers 4

up vote 2 down vote accepted

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

Then in your theme add following code to filter the internal link custom post type

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

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

share|improve this answer
    
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! ;)

share|improve this answer

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");
function disable_link_to_existing_content_shortcode(){
    return false;
}

Hope this will be useful for you!

share|improve this answer

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.