Create separate search forms for products, posts types and posts in WordPress
I will show you how you can add transparent logo or icon watermark using php script on an image(s) and save result image(s). You can align logo or icon using perimeters which are used in imagecopy() php function `` anywhere in wordpress templates. Sometimes client want to get search record from particular categories or taxonomies. i.e. products, custom post types, blogs. You can do this by the following code.
Search records from all
<form method="get" class="search-form" action="<?php echo site_url(); ?>">
<input type="text" class="search-post" name="s" placeholder="<?php echo esc_attr_x( 'Search Posts...', 'placeholder' ) ?>" value="<?php echo get_search_query() ?>" />
<button type="submit" class="search-submit">Search</button>
</form>
Search records from custom posts types software and books only
<form method="get" class="search-form" action="<?php echo site_url(); ?>">
<input type="text" class="search-post" name="s" placeholder="<?php echo esc_attr_x( 'Search Posts...', 'placeholder' ) ?>" value="<?php echo get_search_query() ?>" />
<input type="hidden" name="post_type[]" value="software" />
<input type="hidden" name="post_type[]" value="books" />
<button type="submit" class="search-submit">Search</button>
</form>
Search records from products only
<form method="get" class="search-form" action="<?php echo site_url(); ?>">
<input type="text" class="search-product" name="s" placeholder="<?php echo esc_attr_x( 'Search Products...', 'placeholder' ) ?>" value="<?php echo get_search_query() ?>" />
<input type="hidden" value="product" name="post_type" id="post_type" />
<button type="submit" class="search-submit">Search</button>
</form>
I will show you how you can add transparent logo or icon watermark using php script on an image(s) and save result image(s). You can align logo or icon using perimeters which are used in imagecopy() php function `` anywhere in wordpress templates. Sometimes client want to get search record from particular categories or taxonomies. i.e. products, custom post types, blogs. You can do this by the following code.
Search records from all
<form method="get" class="search-form" action="<?php echo site_url(); ?>">
<input type="text" class="search-post" name="s" placeholder="<?php echo esc_attr_x( 'Search Posts...', 'placeholder' ) ?>" value="<?php echo get_search_query() ?>" />
<button type="submit" class="search-submit">Search</button>
</form>
Search records from custom posts types software and books only
<form method="get" class="search-form" action="<?php echo site_url(); ?>">
<input type="text" class="search-post" name="s" placeholder="<?php echo esc_attr_x( 'Search Posts...', 'placeholder' ) ?>" value="<?php echo get_search_query() ?>" />
<input type="hidden" name="post_type[]" value="software" />
<input type="hidden" name="post_type[]" value="books" />
<button type="submit" class="search-submit">Search</button>
</form>
Search records from products only
<form method="get" class="search-form" action="<?php echo site_url(); ?>">
<input type="text" class="search-product" name="s" placeholder="<?php echo esc_attr_x( 'Search Products...', 'placeholder' ) ?>" value="<?php echo get_search_query() ?>" />
<input type="hidden" value="product" name="post_type" id="post_type" />
<button type="submit" class="search-submit">Search</button>
</form>
Recommanded Articles
- Generate Dummy Posts in WordPress
- How to add captcha in Contact Form 7
- how to create a cron job in wordpress
- How to get form data in Contact Form 7
- Insert Update Delete Select query in WordPress
- How to increase website speed
- Create plugin in WordPress in which create table in DB on activate
- Create new tab under my account WooCommerce frontend
- Custom image sizes in WordPress
- Get posts by meta key and meta value in WordPress
Latest Comments
Jhilmil
27 Dec 2020