Enlight searched text in wordpress search results

January 10, 2009

Many WordPress users find the search function a bit imcomplete. For exemple, it don’t automatically hightlight the searched text. Open your search.php file and find the the_title() function. Replace it with the following: echo $title; Now, just before the modified line, add this code: <?php $title = get_the_title(); $keys= explode(" ",$s); $title = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt">\0</strong>', $title); ?> Save the search.php file and open style.css.... [Read the full story]

Disable search engine indexing on a single wordpress post

January 10, 2009

Most of the time, you want your posts to be indexed by search engines as such as Google as soon as possible. But if for some reason, you don’t want a particular post to be indexed by search engines. first get the ID of the post you’d like to be not indexed by search engines. In this exemple, We assume your post id is 18. Open your header.php file and paste the following code between the <head> and </head> tags: <?php if ($post->ID == 18) { echo '<meta name="robots" content="noindex">'; } That’s... [Read the full story]

Remove category from your WordPress url

January 8, 2009

Ever wanted to be able to finally remove the useless /category/ from your WordPress categories permalinks? If yes, read on and get ready to hack your .htaccess file. By default, WordPress category permalinks are displayed that way: http://www.livexp.net/blog/category/wordpress As you can see, the category in the url is pretty useless. Here’s how to remove it: First backup your .htaccess file. Then, open it and append the following line: RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L] Once saved, your... [Read the full story]

Create a tag page on your WordPress blog

January 7, 2009

The problem of displaying tags in your sidebar is that it isn’t really readable, which caused many wordpress bloggers to get rid of tags. How to create a tage page to display your wordpress blog tags in a more readable manner? To create your tag page, the first thing to do is to create a page template. Paste the following code in it if you don’t know how to create one: <?php /* Template Name: Tags */ <h2>All tags</h2> wp_tag_cloud('number=0'); ?> That’s simple as that! The number=0 parameter specifies... [Read the full story]

Create a Logout button on your WordPress blog

January 6, 2009

Especially in the case of a multi-author blog, it can be really useful to include a logout link on your theme. To create a “Logout” link on your WordPress blog, simply paste the following code on your theme: <a href="<?php echo wp_logout_url(); ?>">Logout</a> Please note that this will work with WordPress 2.7+ only. If you haven’t switched to WP 2.7 yet, the following code will do (almost) the same job: <a href="/wp-login.php?action=logout">logout</a>  Read More →