Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions do not honor exclude_from_search set to true #17619

Open
shaiherman opened this issue Sep 26, 2019 · 3 comments
Open

Suggestions do not honor exclude_from_search set to true #17619

shaiherman opened this issue Sep 26, 2019 · 3 comments
Labels
REST API Interaction Related to REST API [Type] Enhancement A suggestion for improvement.

Comments

@shaiherman
Copy link

Describe the bug
When creating a custom post type with show_in_rest => true and exclude_from_search => true, the search suggestion feature when looking up links, such as the anchor button in the toolbar or the core/button's block link input shows those custom post types.

show_in_rest => false should not be used as a means of filtering suggestions as its reach is far broader. For example my CPT's are using custom blocks and need this option be true.

Why does this matter?
These are links that will be public facing, and as such should not be an option for editors. If so, they will culminate in 404 pages.

Suggestions will return Title's of CPT's and as such many folks will use identical or similar titles in their custom post types, causing confusion on which suggestion is the right one.

To reproduce

  1. Create a CPT called Testimonials with show_in_rest => true and exclude_from_search => true
  2. Add an entry into the CPT with title "Demo Testimonial"
  3. Go to a page, add a paragraph block
  4. Create an anchor on the paragraph block using the toolbar and search for word Testimonial - you will see "Demo Testimonial" in the suggestions

Expected behavior
You should not see Demo Testimonial in any search suggestions if exclude_from_search is set to false.

Additional context
Gutenberg 6.5

Additional idea
Another idea is to show the CPT name and then the title in the suggested results. For example "Page - Testimonials" and "Testimonial - Testimonial Demo" would help prevent such issues.

@shaiherman shaiherman changed the title Suggestions do not honor exclude_from_search set to false Suggestions do not honor exclude_from_search set to true Sep 26, 2019
@swissspidy swissspidy added the REST API Interaction Related to REST API label Sep 27, 2019
@swissspidy
Copy link
Member

exclude_from_search is for excluding post types on the site's search form on the frontend, it is not meant to exclude post types from the link suggestions in the editor.

@shaiherman
Copy link
Author

I suppose you may want to link to a CPT on the front-end and not have it be searchable; this seems like a rare case as long as the link suggestion tool is used for public facing links.

I'm unaware of a better post type argument. show_in_rest is far worse for this need.

I can see three solutions:

  1. A new post type argument - something like exclude_from_suggestions
  2. Better labeling to avoid confusion (see "Additional Idea" in the original issue)
  3. Provide a means of filtering the suggestions on the component level

These solutions should not be viewed as mutually exclusive.

@avillegasn
Copy link
Contributor

exclude_from_search is for excluding post types on the site's search form on the frontend, it is not meant to exclude post types from the link suggestions in the editor.

Is there any way to exclude post types from the link suggestions in the editor?

@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REST API Interaction Related to REST API [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants