Support » Developing with WordPress » Block-Editor: Problem with internal text links to custom taxonomies

  • azurblossom


    Hello to the community,

    I use WP 5.2 with the Gutenberg Editor to create a recipe page. I have created a CPT (recipe) and a Custom Taxonomy (recipe_tax). Everything works fine.

    In the default posts or pages of WP, I tried to set text links to my custom taxonomies that don’t work. At the moment I can only link to articles and pages there.

    After some research I found the following “wp_link_query” function on Github (see also:

    add_filter( 'wp_link_query', 'pm_wp_link_query_term_linking', 99, 2 );
    function pm_wp_link_query_term_linking( $results, $query ) {
      // Query taxonomy terms.
    	$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'names' );
    	$terms = get_terms( $taxonomies, array(
    		'name__like' => $query['s'],
    		'number'     => 20,
        'hide_empty' => false,
    	) );
    	// Check if any taxonomies were found.
    	if ( ! empty( $terms ) ) {
    		foreach ( $terms as $term ) {
          $results[] = array(
            'ID' => 'term-' . $term->term_id,
            'title' => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
            'permalink' => get_term_link( intval( $term->term_id ), $term->taxonomy ),
            'info' => get_taxonomy( $term->taxonomy )->labels->singular_name,
      return $results;

    I added this code to my functions.php to extend the internal linking to my custom taxonomies.

    In the Classic Editor this works smoothly, in the new Block Editor unfortunately not.

    Here are two screenshots to illustrate the problem:

    1. Block Editor (Gutenberg)

    2. Classic Editor:

    I’d appreciate your help.

  • The topic ‘Block-Editor: Problem with internal text links to custom taxonomies’ is closed to new replies.