• Resolved themusicvacuum

    (@themusicvacuum)


    I want to add a search bar to JUST ONE page.

    <form method=”get” id=”searchform” action=”<?php bloginfo(‘url’); ?>/”>
    <input type=”text” onfocus=”if(this.value==’Search here’) this.value=”;” onblur=”if(this.value==”) this.value=’Search here’;” value=”Search here” name=”s” id=”s” />
    </form>

    that is the search form.php.

    If i put it in the page.php template it will appear on all pages.

    Help!?

    Thanks so much.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You can use WordPress Conditional Tags. For example,

    is_page( 42 )
    When Page 42 (ID) is being displayed.

    Thread Starter themusicvacuum

    (@themusicvacuum)

    Thanks Rab!

    Where abouts would I use these tags? For example, if this is my code…

    <form method=”get” id=”searchform” action=”<?php bloginfo(‘url’); ?>/”>
    <input type=”text” onfocus=”if(this.value==’Search here’) this.value=”;” onblur=”if(this.value==”) this.value=’Search here’;” value=”Search here” name=”s” id=”s” />
    </form>

    How would I incorporate my conditional tag into that?

    Sorry but there seems to be very little in way of explanation on this.

    Thanks so much.!

    You will need to add it to page.php where ever you were going to before. If you were using it on page ID 42 only you would put in something like the code below. Just change the 42 value to whatever page ID.

    <?php if(is_page( '42' )) { ?>
    	<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
    	<input type="text" onfocus="if(this.value=='Search here') this.value='';" onblur="if(this.value=='') this.value='Search here';" value="Search here" name="s" id="s" />
    	</form>
    <?php }  ?>
    Thread Starter themusicvacuum

    (@themusicvacuum)

    magic Rab thanks a million.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘SEARCH BAR’ is closed to new replies.