14.9 C
London
Wednesday, April 15, 2026

WordPress Search Redirect to Custom Post Type Archive

- Advertisement -spot_imgspot_img
- Advertisement -spot_imgspot_img

Introduction

This is a small issue but confusing.

You add search form on homepage. User types something.

But result always goes to:
/?s=keyword

You want it to go here:
/customposttype/?s=keyword

But it does not happen.


What is Happening

WordPress search works in one simple way.

It looks for s value in URL.

Example:

By default, it shows results on main search page.

It does not care about custom post type unless you tell it.


Why Your Setup Not Working

You may try hidden input or other tricks.

But main problem is not query.

Problem is form action.

Form is sending data to wrong place.

So WordPress loads default search page.


Simple Working Fix

Just change form action.

Instead of this:

<form action="/" method="get">

Use this:

<form action="/customposttype/" method="get">

Full example:

<form action="/customposttype/" method="get">
  <input type="search" name="s" placeholder="Search">
  <button type="submit">Search</button>
</form>

Important Things

  • action must be archive URL
  • name="s" must be there

Without s, WordPress search will not work.


How It Works

When user submits:

  • Request goes to /customposttype/
  • Query ?s=keyword is added
  • WordPress shows filtered results in that archive

Simple flow.


Elementor Case

If you use Elementor form:

Sometimes you cannot change action easily.

In that case:

  • Use HTML widget
  • Add your own form

Or check Elementor settings for form action.


Multiple Search Forms

You can make many forms like this:

  • /courses/
  • /events/
  • /products/

Each form points to different archive.


Small Example

One site had course and event posts.

Default search was mixing everything.

They made two forms:

  • Courses โ†’ /courses/
  • Events โ†’ /events/

Now results are clean and correct.


Common Mistakes

  • Using wrong action URL
  • Missing name="s"
  • Archive page not enabled
  • Using default widget without control

Quick Check

Make sure:

  • Archive is enabled (has_archive = true)
  • URL works directly
  • Form action matches archive

FAQs

Why search goes to default page?

Form action is /

What should be input name?

s

Can I use many search forms?

Yes

Need plugin?

No

Will it work for CPT?

Yes, if archive is enabled


Final

This is not big problem.

Just send search request to correct URL.

After that, WordPress shows results in right place.

Simple fix, no plugin needed

- Advertisement -spot_imgspot_img
Latest news
- Advertisement -spot_img
Related news
- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here