how to add search function to site

Tai

HEAD CAPTAIN
Staff member
Administrator
May 11, 2003
14,311
2
2,694
515
United Kingdom
Searching and searching and found no joy. I want to add a simple search bar to my site that does an internal global site search, all I can find on google is how to add a google search to your site (what a surprise)

Can anyone link me or tell me how?
 

Gezza

Golden Oldie
Golden Oldie
Sep 23, 2008
2,201
61
155
uk
You using wordpress ? if so just search for a plugin.
 

Gezza

Golden Oldie
Golden Oldie
Sep 23, 2008
2,201
61
155
uk
You could do google custom search and just add your site to the list. Just found this on my site, don't know if any use to you.

search form
Code:
<?php $search_text = empty($_GET['s']) ? "Search" : get_search_query(); ?> 
<div id="search">
    <form method="get" id="searchform" action="<?php bloginfo('home'); ?>/"> 
        <input type="text" value="<?php echo $search_text; ?>" 
            name="s" id="s"  onblur="if (this.value == '')  {this.value = '<?php echo $search_text; ?>';}"  
            onfocus="if (this.value == '<?php echo $search_text; ?>') {this.value = '';}" />
        <input type="image" src="<?php bloginfo('template_url'); ?>/images/search.gif" style="border:0; vertical-align: top;" /> 
    </form>
</div>

search results
Code:
<?php get_header(); ?>
<div class="outer" id="contentwrap">
    <?php get_sidebars('left'); ?>
	<div class="postcont">
		<div id="content">

	<?php if (have_posts()) : ?>

		<h2 class="pagetitle">Search Results</h2>

		<?php while (have_posts()) : the_post(); ?>

			<div <?php post_class('post') ?>>
                <h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
				<div class="postdate"><img src="<?php bloginfo('template_url'); ?>/images/date.png" /> <?php the_time('F jS, Y') ?> <img src="<?php bloginfo('template_url'); ?>/images/user.png" /> <?php the_author() ?> <?php if (current_user_can('edit_post', $post->ID)) { ?> <img src="<?php bloginfo('template_url'); ?>/images/edit.png" /> <?php edit_post_link('Edit', '', ''); } ?></div>
				<div class="entry">
                    <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(200,160), array("class" => "alignleft post_thumbnail")); } ?>
					<?php the_excerpt() ?>
                    <div class="readmorecontent">
						<a class="readmore" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Read More »</a>
					</div>
				</div>
        	</div>

		<?php endwhile; ?>

		<div class="navigation">
			<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
			<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
			<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
			<?php } ?>
		</div>

	<?php else : ?>

		<h2 class="pagetitle">No posts found. Try a different search?</h2>
		<?php get_search_form(); ?>

	<?php endif; ?>

		</div>
	</div>

<?php get_sidebars('right'); ?>
</div>
<?php get_footer(); ?>
 

Tai

HEAD CAPTAIN
Staff member
Administrator
May 11, 2003
14,311
2
2,694
515
United Kingdom
Thanks I'll check it out.

@Gezza im not really skilled enough to understand that lol

---------- Post added 20-08-2011 at 03:59 PM ---------- Previous post was 07-08-2011 at 01:09 PM ----------


tried that, no good. I don't want google ads all over my site when someone searches. is there no simple-ish way to add a proper "home made" search function to my site?
 

Tai

HEAD CAPTAIN
Staff member
Administrator
May 11, 2003
14,311
2
2,694
515
United Kingdom
http://www.scriptarchive.com/search.html

However with search functions, you will need to learn to code. Cause you can't expect to produce a website from scratch without learning, unless you've used a pre programed system.

You've seen my other thread so I can only assume you already know that I'm learning to code. In fact I've already built most of my site.

Anyway that search is no good either, as it only searches file names, not content within the files. Lame. Who knew? I should've just used wordpress but I wanted to design the theme from scratch and figured it would be easier to create a template for a standard html website than it would be for something like wordpress.