Wednesday, December 16, 2009

12/17 WP Switch

Please add updates@feedmyinbox.com to your address book to make sure you receive these messages in the future.
WP Switch - Just another WordPress weblog Feed My Inbox

How to Highlight Search Terms with jQuery
December 16, 2009 at 3:25 pm

A neat way to spice up your WordPress search page is to highlight search terms within your search results. The solution described in this tutorial will highlight both the title and post content and is a drop-in modification for WordPress.

Paste the following code in your theme's functions.php file.

 function hls_set_query() {   $query  = attribute_escape(get_search_query());   if(strlen($query) > 0){     echo '       <script type="text/javascript">         var hls_query  = "'.$query.'";       </script>     ';   } } function hls_init_jquery() {   wp_enqueue_script('jquery'); } add_action('init', 'hls_init_jquery'); add_action('wp_print_scripts', 'hls_set_query'); 

After that you need to open your theme's header.php and paste the following code before the < /head > tag.

 <style type="text/css" media="screen">   .hls { background: #D3E18A; } /* <- Change the CSS style of */                                 /*    highlighted texts here. */ </style> <script type="text/javascript"> jQuery.fn.extend({   highlight: function(search, insensitive, hls_class){     var regex = new RegExp("(<[^>]*>)|(\\b"  search.replace(/([-.* ?^${}()|[\]\/\\])/g,"\\$1")  ")", insensitive ? "ig" : "g");     return this.html(this.html().replace(regex, function(a, b, c){       return (a.charAt(0) == "<") ? a : "<strong class=\""  hsl_class  "\">"   c   "</strong>";     }));   } }); jQuery(document).ready(function($){   if(typeof(hls_query) != 'undefined'){     $("#post-area").highlight(hls_query, 1, "hls"); // <- Change 'post-area' to ID of HTML tag you                                                     //    want to highlight search terms in.   } }); </script> 

Make sure you change “post-area” in the code to the HTML tag ID of the area you want your search terms highlighted. You can also change the way the highlighted text look by changing the CSS properties of the “.hls” class.

Related posts:

  1. How to Highlight Author Comments in WordPress
  2. Adding a search bar to the NextGEN Gallery Plugin
  3. Add Breadcrumbs to WordPress Without a Plugin


Daily Design Links #1
December 16, 2009 at 8:05 am

1. A Comparison of 6 Popular Wordpress Frameworks

Being that most of us are working against multiple deadlines at one time, we need to be able to save ourselves as much time and headache as possible, and help prevent ourselves from unnecessarily re-inventing the wheel. That is why frameworks are such a time and life saver in the development arena.

2. 49 Most Creative Photoshop Tutorials of 2009

What a year it has been for Photoshop… so many new techniques, so many fresh ideas and so many new and creative web sites offering free tutorials. In this post we have collected the best of them, focusing on photo manipulation, design and drawing, poster design, caricature design and finally, illustration within Photoshop.

3. Optimizing WordPress for Search Engines

In this article, I will go over a few steps you should take to optimize your WordPress installation for search engines. While WordPress has good SEO features out of the box, these tips will help you maximize your search engine results while also making sure your site is the best it can be.

4. Advanced Power Tips for WordPress Template Developers: Reloaded

Covers customizing basic content administration and adding features to the post and page editor in WordPress.

5. 20+ Tools for Quick and Clean Code Development

Being able to code a site using a variety of tools lets you simplify the coding process while you take a big bite out of saving time.

6. Comment Design: Considerations, Best Practices and Examples

Taking the time to design your comments, and your comment form, can make a huge impression on your regular visitors. It subconsciously implies you care about their opinion and want them to engage in discussion on your site. You'll find some best practices and examples of creating a beautiful commenting system on your next blog design.

7. a Guide to Writing Killer Content for your Design Blog

If you are an editor of a design blog, then you would be fairly familiar with the rigorous demands involved in churning quality, thought-provoking articles on a daily or fortnightly basis. The truth of the matter is that many blog writers have resorted to rehashing arguments and topics that have already been exhaustively discussed before.

8. The Funniest T-Shirt Designs of the Decade

Yesterday I was looking for some t-shirts to buy for Christmas and I started browsing through Threadless and other sites. As usual there were some beautiful illustrations and, of course, very funny ones. Then I decided to select the funniest ones and share them with you at Abduzeedo.

No related posts.

 

This email was sent to asif2bd+wpnewspost@gmail.comManage Your Account
Don't want to receive this feed any longer? Unsubscribe here.

No comments:

Post a Comment