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

Add pages to suggestions for UrlInput #7951

Closed
skript-cc opened this issue Jul 13, 2018 · 5 comments
Closed

Add pages to suggestions for UrlInput #7951

skript-cc opened this issue Jul 13, 2018 · 5 comments
Labels
REST API Interaction Related to REST API [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed

Comments

@skript-cc
Copy link

Issue Overview

I'm using Gutenberg in a project for which I only need to use pages, not posts. The UrlInput only shows suggestions for posts, which makes linking to pages impossible without typing or pasting the url. It would be very nice if pages would show up as suggestions as well or at least have the possibility to customize the suggestions of the UrlInput. When I look at the current implementation this seems to be impossible too.

Steps to Reproduce (for bugs)

  1. Ensure there are some pages
  2. On another page insert a paragraph
  3. Select some text and try to insert a link
  4. Start typing in the url input

Expected Behavior

Pages should come up in the suggestions.

Current Behavior

Only posts are showing up.

Possible Solution

Include pages in the suggestions by default or make it possible to customize the suggestions.

@paulwilde
Copy link
Contributor

I feel this should also include public custom post types as well.

@LukasFritzeDev
Copy link

LukasFritzeDev commented Jul 14, 2018

Oh. The problem is the usage of the posts endpoint from the rest api. You can cheat a bit and customize the query params with a small filter:

add_filter( 'rest_post_query', 'postRestQueryArgs' );
function postRestQueryArgs( $args ) {
    if ( $args[ 'orderby' ] === 'relevance' ) {
        $args[ 'post_type' ] = array( 'post', 'page' );
    }
   return $args;
}

Or if you are lazy and want to include all post types just use
$args[ 'post_type' ] = 'any';

I know it kills the sense of the posts endpoint. It would be a better solution to have a GET parameter for example to set the required post types,. This is only a quick and dirty solution.

@chrisvanpatten
Copy link
Member

I think this is covered by the changes in #7894. I know @danielbachhuber has been guiding that with @felixarntz — maybe one of you can confirm and potentially tag or close this issue?

@danielbachhuber
Copy link
Member

Yes, this issue is a duplicate of #2084

@danielbachhuber danielbachhuber added REST API Interaction Related to REST API [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed labels Jul 14, 2018
@skript-cc
Copy link
Author

Thanks for the info and sorry for the duplicate. A search didn't brought similar issues up.

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 [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed
Projects
None yet
Development

No branches or pull requests

5 participants