1. PROMO Upgrade to Pro Membership @ $99 / Lifetime & access all our 16+ premium Divi extensions: Divi Block, Carousel Toolkit, etc.LEARN MORE
Dismiss Notice
NEW Divi.Help Pro Carousel AI Toolkit - Magically turn your Divi design into carousel, simply by using our online toolkit. No plugins needed. Now it works with Divi 5 as well!Try our carousel AI toolkit
BEST Divi Block - A revolutionary drag & drop tool to easily mix & match 960+ premade blocks (Light & Dark) to kick start your Divi site design. Special module designs are included as well. Also newly added AI generator & color. Now it works with Divi 5 as well!
Learn More About Divi BlockFree Version ~ 340+ Free Blocks

Search by post type in Divi search form

Discussion in 'Free Divi Community Forum' started by Grupo Bundle, Sep 25, 2019.

  1. Grupo Bundle

    Grupo Bundle New Member
    Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    Hello!

    I am trying to make Divi search do the following:

    If I am on a page and I do a search the results are only pages.

    If I am in the blog and I do a search the results are only blog entries.

    I found this, but it doesn;t work for me or I didn't know how to use

    https://www.coderrr.com/wordpress-search-only-posts-or-pages/

    Also I see this post

    https://divi.help/threads/how-to-make-divi-search-like-wocommerce-items-search.641/

    I think this is something like I'm looking for but how to add the conditions?

    <input type="search" class="et-search-field" placeholder="%1$s" value="%2$s" name="s" title="%3$s" /><input type="hidden" name="post_type" value="post" />

    Thank you
     
    1. PRO MEMBER PERKS Divi Block Pro - Premade floating button design for your Divi site without using any plugins:View Demo
  2. Divi.Help

    Divi.Help Administrator
    Staff Member

    The coderrr link that you shared seems to be the same + conditional statement, so it should work just fine.

    Just add their code right behind the <input type="search" class="et-search-field" placeholder="%1$s" value="%2$s" name="s" title="%3$s" />
    Code:
    Log In or Sign Up to view this code.
    But do note that if you add the code in header.php, then it will only works for default Divi header.

    It will not work with injected custom header.
     
  3. Grupo Bundle

    Grupo Bundle New Member
    Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    Thank you, but it still searching in Blog when I'm on a page, and when I'm on a Blog it still searching in Pages.

    I tried to create a custom search creating the file searchform.php but it seems that it does not work when using Divi

    Is there a other way to do it?

    Thank you
     
    1. PRO MEMBER PERKS Divi Block Pro - Premade horizontal timeline design for your Divi site without using any plugins:View Demo
  4. Divi.Help

    Divi.Help Administrator
    Staff Member

    Kindly share your URL where editing the header.php didn't work.