Opened 14 years ago
Closed 14 years ago
#21033 closed enhancement (duplicate)
Add filter hook for internal linking of custom post type in wordpress editor
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.4 |
| Component: | Editor | Keywords: | |
| Focuses: | Cc: |
Description
Currently wordpress displays all public post types at the time of selecting internal links through insert/edit link button in the wordpress tinymce editor.
By providing a filter for the custom post types can be a good feature for a good CMS.
In file wp-includes/class-wp-editor-php
line no 711
public static function wp_link_query( $args = array() ) {
$pts = get_post_types( array( 'public' => true ), 'objects' );
$pt_names = array_keys( $pts );
$query = array(
'post_type' => $pt_names,
'suppress_filters' => true,
'update_post_term_cache' => false,
'update_post_meta_cache' => false,
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'post_date',
'posts_per_page' => 20,
);
eg solution
$pts = get_post_types( array( 'public' => true ), 'objects' );
$pt_names = apply_filters('custom_insert_link_suggestion_filter',array_keys( $pts ));
$query = array(...
we can add some sort of filter say wp_custom_post_type_link_suggest_filter
so that we can allow only certain post types.
Eventually in our theme function
function my_filter_function($allowed_post_types)
{
if( <condition chek>)
{
return array('page','<CPT>');
}
}
add_filter('custom_insert_link_suggestion_filter','my_filter_function',10,1);
Change History (1)
Note: See
TracTickets for help on using
tickets.
#18042