Title: wp_link_query_args
Published: April 25, 2014
Last modified: April 28, 2025

---

# apply_filters( ‘wp_link_query_args’, array $query )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#parameters)
 * [More Information](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#wp--skip-link--target)

Filters the link query arguments.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#description)󠁿

Allows modification of the link query arguments before querying.

### 󠀁[See also](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#see-also)󠁿

 * [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/): for 
   a full list of arguments

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#parameters)󠁿

 `$query`array

An array of [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/)
arguments.

## 󠀁[More Information](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#more-information)󠁿

The “`wp_link_query_args`” filter is used to filter the array of arguments passed
to the `wp_link_query` function which is responsible for building the list of linkable
content in the modal window that displays when you insert a link. `wp_link_query_args`
allows you to alter the query before the list is rendered on the page.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#source)󠁿

    ```php
    $query = apply_filters( 'wp_link_query_args', $query );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-editor.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-editor.php#L1813)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-editor.php#L1813-L1813)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#related)󠁿

| Used by | Description | 
| [_WP_Editors::wp_link_query()](https://developer.wordpress.org/reference/classes/_wp_editors/wp_link_query/)`wp-includes/class-wp-editor.php` |

Performs post queries for internal linking.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.7.0](https://developer.wordpress.org/reference/since/3.7.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/wp_link_query_args/?output_format=md#comment-content-4846)
 2.    [Steven Lin](https://profiles.wordpress.org/stevenlinx/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/wp_link_query_args/#comment-4846)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_link_query_args%2F%23comment-4846)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_link_query_args%2F%23comment-4846)
 4.  Example Migrated from Codex:
 5.  Any allowable [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/)
     parameters can be passed to `wp_link_query_args`. One example is filtering out
     post types:
 6.  **Show only posts and pages**
 7.  If you wanted only allow posts and pages to show up in the linked results, you
     could do something like this. In this example, we’re going to check to make sure
     we aren’t in the admin, so results would only be filtered on the front end, but
     admins could still add links to all post types.
 8.      ```php
         add_filter( 'wp_link_query_args', 'my_wp_link_query_args' ); 
     
         function my_wp_link_query_args( $query ) {
             // check to make sure we are not in the admin
             if ( !is_admin() ) {
                 $query['post_type'] = array( 'post', 'pages' ); // show only posts and pages
             }
     
             return $query;
         }
         ```
     
 9.  **Remove specific post types from results**
 10. You’d use something like this if you only wanted to remove specific post types
     from the results.
 11.     ```php
         add_filter( 'wp_link_query_args', 'remove_these_post_types_from_wp_link_query_args' );
     
         function remove_these_post_types_from_wp_link_query_args( $query ) {
             // this is the post type I want to exclude
             $cpt_to_remove = 'article';
     
             // find the corresponding array key
             $key = array_search( $cpt_to_remove, $query['post_type'] ); 
     
             // remove the array item
             if( $key )
                 unset( $query['post_type'][$key] );
     
             return $query;
         }
         ```
     
 12.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_link_query_args%2F%3Freplytocom%3D4846%23feedback-editor-4846)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_link_query_args%2F)
before being able to contribute a note or feedback.