how to add Search box in Header : price comparison theme

WordPress Business Themes Forums Responsive Themes Comparison Theme how to add Search box in Header : price comparison theme

how to add Search box in Header : price comparison theme

March 20, 2017
 Majeed

  • Majeed
    Newbie 7 points

    Dear ,
    can anyone experties give custom code for :

    1) How to add advance search box in Menu header bar ? any custom code?

    March 20, 2017 at 5:32 am
  • Josh
    Josh
    Super Guru 13,887 points

    Hello Majeed,
    Please go to Theme Setup >General Setup >Main Menu >Select MENU+SEARCH

    March 20, 2017 at 12:22 pm

  • Majeed
    Newbie 7 points

    Dear sir,
    my website url is : foodycompare.com

    Since i’m using child theme of price comparison theme , i won’t get menu option through Theme Setup >General Setup >Main Menu >Select MENU+SEARCH.

    So please help me give some custom code or tell me where can i edit to get search bar in header

    March 20, 2017 at 2:03 pm
  • Josh
    Josh
    Super Guru 13,887 points

    You will need customization to add an advanced search.The file to edit is header-menu.php If unsure how to do this I would suggest you hire someone to help.Please post here >>www.premiumpress.com/designwork/

    March 20, 2017 at 3:23 pm
  • Chuck
    Chuck
    Newbie 70 points

    Very simple procedure with 2 plugins. Here’s how I did it.

    You need 2 different plugins.

    1. https://wordpress.org/plugins/shortcode-in-menus/
    2. https://wordpress.org/plugins/php-code-for-posts/ (which is a VERY handy plugin to have for many other projects)

    Steps:
    1. Install & activate both plugins.

    2. Go to PHP code for posts plugin by clicking the WP menu option “PHP Code” and create a new snippet (aka shortcode) with the following code, changing YOURSITE.com with your own domain…

    <form role="search" method="get" id="searchform" class="navbar-form" action="http://YOURSITE.com/">
    <div class="form-group">
    	<input type="text" name="s" id="s" class="form-control"value="<?php if(isset($_GET['s'])){ echo strip_tags($_GET['s']); } ?>" placeholder="<?php echo "Search"; ?>">
    </div>
    <input id="searchsubmit" value="Search" class="btn btn-primary" type="submit">
    </form>

    Then save the snippet.

    3. Go to Appearance >> menus in wordpress and select the menu you want to add the search bar to.

    4. In the left hand side, choose the “Shortcode” option (which was created by the “Shortcode in Menus” plugin). For the title, name it whatever you want, like “Header Menu Search Bar”, it doesn’t matter what you name it. In the large box where your shortcode goes, paste the php snippet you created in step one which should be [php snippet=1] assuming you never used that plugin for anything else up to this point.

    5. Click “add to menu”

    March 29, 2017 at 1:14 pm
  • Josh
    Josh
    Super Guru 13,887 points

    Thanks for sharing Chuck :)

    March 29, 2017 at 1:42 pm

  • Majeed
    Newbie 7 points

    Dear Chunk,
    Thank you for your effort… God bless you !
    But code is not working for me …
    I did same as you explained ( i tried this on my aother domain foodykart.com, with same comparisonpress theme )
    but getting error like below ….plz help

    Parse error: syntax error, unexpected ‘<‘ in /home/foodykar/public_html/wp-content/plugins/php-code-for-posts/Classes/Shortcode.php(95) : eval()’d code on line 3

    March 29, 2017 at 7:00 pm
  • Chuck
    Chuck
    Newbie 70 points

    Would you mind giving me access to your wordpress backend? There’s no way I can troubleshoot this on the forum. The error makes no sense to me unless I see the code you pasted into the PHP Code for Posts plugin.

    If you’re willing to give me access, email me at vrepublishing at gmail with your site’s login details.

    March 29, 2017 at 7:23 pm
  • Chuck
    Chuck
    Newbie 70 points

    Also, how did you get those arrows on your categories in your advanced search widget?

    See attached picture…

    Attachments:
    You must be logged in to view attached files.
    March 29, 2017 at 8:40 pm

  • Majeed
    Newbie 7 points

    Dear Chunk,
    i have sent you login details , please find at vrepublishing@gmail.com

    Thank you

    March 30, 2017 at 5:22 am
  • Chuck
    Chuck
    Newbie 70 points

    Got it and fixed. For anyone wondering what was wrong, Majeed wrapped the code I posted above in PHP tags. In other words, he started the code with <?php and ended it with ?>. This caused an error because the code is not PHP code, it’s HTML code with 2 pieces of php which already have the php tags on them.

    I know the reason why Majeed did this: because the PHP code for posts plugin tells you to make sure you begin and end your code with <?php and ?> respectively. But this is only true if you are making a PHP code snippet. The plugin author should remove this instruction because the plugin can create snippets for any type of code, not just PHP (making the name of the plugin also incorrect, but I digress :)).

    Anyway, this method I laid out above works fine. The only downside being you have to reply on plugins.

    Also, be aware that there is a chance it may not work with some of the other child themes. The problem being that you need to use a different code for your search form. The only thing you can do is try it. If it does not work, you can then just remove the plugins and forget about it or you need to find the code that your child theme uses for a search form and use that instead of my code.

    Be aware that making any changes like this to any theme/child theme could possibly eventually be rendered useless or break your site when you update your theme to a newer version. That is the downside to making mods to a PP site, whether you’re using plugins to make the changes or modifying the code of the theme files directly. This is the downside to using out-of-the box solutions of any kind, not just PP. They are constantly evolving and changing so you have to make sure your mods are also constantly evolving and changing with it.

    March 30, 2017 at 5:51 pm
Viewing 11 posts - 1 through 11 (of 11 total)

Didn't find what you were after?

Chat with us now

or contact our support team