<?php if(strpos($_SERVER['REQUEST_URI'], 'news_events') !== false) { ?>
<h4>Search News & Events</h4>
<form class="col-md-12" style="margin: 0 0 0 0; padding: 0; width:100%; display: block; position: relative;" id="searchform" action="<?php bloginfo('home'); ?>/" method="get">
<input id="s" maxlength="150" name="s" type="text" value="" class="txt col-md-12" placeholder="Search News & Events..." />
<input name="post_type" type="hidden" value="news_events" />
</form>
<?php } else { ?>
<h4>Search Articles</h4>
<form class="col-md-12" style="margin: 0 0 0 0; padding: 0; width:100%; display: block; position: relative;" id="searchform" action="<?php bloginfo('home'); ?>/" method="get">
<input id="s" maxlength="150" name="s" type="text" value="" class="txt col-md-12" placeholder="Search Articles..." />
<input name="post_type" type="hidden" value="post" />
</form>
<?php } ?>
Based on the URL this will change searches to display a specific search for a specific post type, and then only show search results based on the search criteria.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.