I have created a custom post type with parameter ‘public’ set to true. This is because I have to have it accessible in plugins that help you to build queries for post display, such as the Views (part of Toolset) plugin.
On the other hand, when I create a new post or page and use the link builder I don’t want entries of this post type to show up in the search box there. Is there any way to achieve this aim?
Versions <= 3.6.1
It looks like the function
wp_link_query()
is used to display the internal posts/pages when you press the Or link to existing content in the “link builder”:wp_link_query()
is defined in/wp-includes/class-wp-editor.php
.It is queried via the
wp_ajax_wp_link_ajax()
, defined in the file/wp-admin/includes/ajax-actions.php
.These functions don’t have any explicit filters to change the query.
Version 3.7 (?)
It looks like there are patches on the way introducing the filter
wp_link_query_args
You can check it out here:
http://core.trac.wordpress.org/ticket/18042
The milestone is set as
3.7
, so this might be your lucky version 😉If that’s the case, then you might probably fix this with:
Example 1:
If you want to list the custom post types by hand:
Example 2:
If you only want to eliminate a single custom post type, but keep all the others, then you can try:
where I used the demo slug
'news'
.And here’s how you would remove an array of post types from the edit link dialog: