How to search by author?

This is our site: https://prairie-health-blog.vercel.app/

Where you can see if you search by any post title it shows the results but if we search by author nothing appears.

URL of WP Rest API is: https://www.prairiehealth.co/blog/wp-json/wp/v2/posts

Is it possible to search by author name?

Also after search the search texts remain in the search form, how we can remove / clear it after we go to home or other pages?

Our site is based on mars theme.

Thank You. Any help will be appreciable.

Hi @zakirsajib

WordPress already provides a link that can be directly used to get the posts of a specific author. You can see these links working in the Twenty Theme for example

https://twentytwenty.frontity.org/author/davidarenas/

These type of links are of the Archive type of pages in WordPress which means they’re a list of posts (or any other custom post type)

In the Twenty Twenty theme these type of links are managed by the <Archive> component

src/components/index.js


<Switch>
  ...
  <Archive when={data.isArchive} />
  ...
>/Switch>

In the Mars Theme these type of links are managed by the <List> component

src/components/index.js

<Switch>
  ...
  <List when={data.isArchive} />
  ...
</Switch>

Hope this helps