# EzSticky

Last version is 0.2 released on 21 November 2006

EzSticky is a simple wordpress plugin that can show post’s excerpt of specified category.
Category tagged as “sticky” is default, i suggest to create it.

Installation: Copy the above code, put it in your /wp-content/plugins/ directory and activate through the administration panel.

Usage: put the function anywhere in the template and add these lines to your css ( if you like it … )

Example: For an example of EzSticky in action, see my blog’s homepage

Alternative: Some clever people have written other plugins that do similar things:

  • Easy Announcement
    An easy way to display announcement on your site without have to edit your theme file.

Changelog:

  • v0.2
  • add sticky_cat param for change category filter selection
  • add $wpdb before table name
  • add some comments
  • v0.1
  • Initial release

Any suggestion are welcome.

  1. <?php
  2. /*
  3. Plugin Name: EzSticky
  4. Plugin URI: http://maurizio.mavida.com/ezsticky
  5. Description:  Show post_excerpt of specified categoty, sticky is default. Usage: put the function ezsticky() anywhere in the template.
  6. Version: 0.2
  7. Author: maurizio
  8. Author URI: http://maurizio.mavida.com
  9. */
  10.  
  11. /*
  12. License: GPL
  13. Installation:
  14. Place the ezsticky.php file in your /wp-content/plugins/ directory
  15. and activate through the administration panel.
  16. */
  17.  
  18. /* 
  19. This program is free software; you can redistribute it and/or modify
  20. it under the terms of the GNU General Public License as published by
  21. the Free Software Foundation; either version 2 of the License, or
  22. (at your option) any later version.
  23. This program is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  26. GNU General Public License for more details.
  27. You should have received a copy of the GNU General Public License
  28. along with this program; if not, write to the Free Software
  29. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  30. */
  31.  
  32.  
  33. /* Changelog
  34. * 2006-11-21 - v0.2
  35. - add sticky_cat param for change category filter selection
  36. - add $wpdb before table name
  37. - add some comments
  38. * 2006-11-20 - v0.1
  39. - Initial release
  40. */
  41.  
  42. function ezsticky ($sticky_cat = 'sticky', $before_title = '<h3>', $after_title = '</h3>', $before_post = '<div>', $after_post = '</div>' ) {
  43.  
  44.     global $wpdb, $tableposts;
  45.  
  46.     $sql = '';
  47.     $sql .= "SELECT ID, post_title, post_content, post_excerpt, category_id, cat_name ";
  48.     $sql .= "FROM $wpdb->posts ";
  49.     $sql .= "INNER JOIN $wpdb->post2cat ON $wpdb->posts.id = $wpdb->post2cat.post_id ";
  50.     $sql .= "INNER JOIN $wpdb->categories ON $wpdb->post2cat.category_id = $wpdb->categories.cat_id ";
  51.     $sql .= "WHERE post_status = 'publish' and cat_name = '$sticky_cat' ";
  52.     $sql .= "ORDER BY post_date ";
  53.    
  54.     $posts = $wpdb->get_results($sql);
  55.         $output = '';
  56.     foreach ($posts as $post) {
  57.         $post_title = stripslashes($post->post_title);
  58.         $post_title = str_replace('"', '', $post_title);
  59.         //$post_title = substr($post_title, 0, 25);
  60.         $permalink = get_permalink($post->ID);
  61.                 $post_content = strip_tags($post->post_content);
  62.                 $post_content = stripslashes($post_content);
  63.        
  64.         $post_excerpt = stripslashes($post->post_excerpt);
  65.        
  66.        
  67.         $output .= '<div class="ezsticky">';
  68.         $output .= $before_title;
  69.         $output .= '<a href="' . $permalink . '" rel="bookmark" title="' . $post_title . '">' . $post_title . '</a>';
  70.         $output .= $after_title;
  71.  
  72.         $output .= $before_post;
  73.         $output .= $post_excerpt ;
  74.                 $output .= ' ( <a href="' . $permalink . '" rel="bookmark" title="' . $post_title . '">Continua ...</a> )';
  75.         $output .= $after_post;
  76.         $output .= '</div>';
  77.         }
  78.    
  79.         echo $output;
  80. }
  81. ?>

  1. .ezsticky {
  2.     width: 490px;
  3.         color: #060;
  4.         background-color: #EDF3F3;
  5.         text-align: left;
  6.         border: 1px dotted #A4B5BD;
  7.         font-size: 12px;
  8.         padding: 5px;
  9.         font-family: Verdana, Arial, Helvetica, sans-serif;
  10.     margin: 0px;
  11.     margin-bottom: 10px;
  12. }       
  13.  
  14. .ezsticky h3 { margin: 5px 0px; }     
  15. .ezsticky h3 a { color: #697C82; }     
  16. .ezsticky div { margin-left: 10px; }


Twitter