Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#21033 closed enhancement (duplicate)

Add filter hook for internal linking of custom post type in wordpress editor

Reported by: caseydipesh Owned by: Dipesh KC
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: Editor Keywords:
Focuses: Cc:


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>');


Change History (1)

#1 @ocean90
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Type changed from feature request to enhancement
Note: See TracTickets for help on using tickets.