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.
- <?php
- /*
- Plugin Name: EzSticky
- Plugin URI: http://maurizio.mavida.com/ezsticky
- Description: Show post_excerpt of specified categoty, sticky is default. Usage: put the function ezsticky() anywhere in the template.
- Version: 0.2
- Author: maurizio
- Author URI: http://maurizio.mavida.com
- */
- /*
- License: GPL
- Installation:
- Place the ezsticky.php file in your /wp-content/plugins/ directory
- and activate through the administration panel.
- */
- /*
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- /* Changelog
- * 2006-11-21 - v0.2
- - add sticky_cat param for change category filter selection
- - add $wpdb before table name
- - add some comments
- * 2006-11-20 - v0.1
- - Initial release
- */
- function ezsticky ($sticky_cat = 'sticky', $before_title = '<h3>', $after_title = '</h3>', $before_post = '<div>', $after_post = '</div>' ) {
- $sql = '';
- $sql .= "SELECT ID, post_title, post_content, post_excerpt, category_id, cat_name ";
- $sql .= "FROM $wpdb->posts ";
- $sql .= "INNER JOIN $wpdb->post2cat ON $wpdb->posts.id = $wpdb->post2cat.post_id ";
- $sql .= "INNER JOIN $wpdb->categories ON $wpdb->post2cat.category_id = $wpdb->categories.cat_id ";
- $sql .= "WHERE post_status = 'publish' and cat_name = '$sticky_cat' ";
- $sql .= "ORDER BY post_date ";
- $posts = $wpdb->get_results($sql);
- $output = '';
- foreach ($posts as $post) {
- //$post_title = substr($post_title, 0, 25);
- $permalink = get_permalink($post->ID);
- $output .= '<div class="ezsticky">';
- $output .= $before_title;
- $output .= '<a href="' . $permalink . '" rel="bookmark" title="' . $post_title . '">' . $post_title . '</a>';
- $output .= $after_title;
- $output .= $before_post;
- $output .= $post_excerpt ;
- $output .= ' ( <a href="' . $permalink . '" rel="bookmark" title="' . $post_title . '">Continua ...</a> )';
- $output .= $after_post;
- $output .= '</div>';
- }
- echo $output;
- }
- ?>
- .ezsticky {
- width: 490px;
- color: #060;
- background-color: #EDF3F3;
- text-align: left;
- border: 1px dotted #A4B5BD;
- font-size: 12px;
- padding: 5px;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- margin: 0px;
- margin-bottom: 10px;
- }
- .ezsticky h3 { margin: 5px 0px; }
- .ezsticky h3 a { color: #697C82; }
- .ezsticky div { margin-left: 10px; }














