/ Published in: PHP
Show post_excerpt where categoty is sticky
Expand |
Embed | Plain Text
<?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; } ?>
You need to login to post a comment.
