Problem: I have a WYSIWYG field that includes a link button. I would like to restrict existing content links by post type.
Solution: The following code sample shows how to restrict entire post types from the existing content link menu:
// filter custom post types out of existing content link options in tinyMCE function custom_wp_link_query_args($query) { $pt_new = array(); $exclude_types = array( 'book', 'chapter' ); foreach ($query['post_type'] as $pt) { if (in_array($pt, $exclude_types)) continue; $pt_new[] = $pt; } $query['post_type'] = $pt_new; return $query; } add_filter('wp_link_query_args', 'custom_wp_link_query_args');
Relevant Documentation:
https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_link_query_args
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 5 years, 11 months ago.
Assisted by: Christian Cox.