kojisin
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: SingleCat plugini came across the same problem.
i believe the problem is, this plug doesn’t follow the rule below.
http://codex.wordpress.org/Shortcode_API#Outputfollowing is a rubbish maybe, but works for me.
--- singlecat/singlecat.php.orig 2009-10-06 21:46:00.000000000 +0900 +++ singlecat/singlecat.php 2009-10-07 02:05:26.000000000 +0900 @@ -11,12 +11,14 @@ //Actions add_shortcode('singlecat', 'sc_shortcode'); + function sc_shortcode($attr) { $level = $attr['view']; $cat = $attr['cat']; $posts = $attr['posts']; $view = 0; + $output = ""; if($level != "public" && $level != "private"): $level = "private"; @@ -41,31 +43,31 @@ $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('category_name='.$catname->name.'&showposts='.$posts.'&paged='.$paged); - - while ($wp_query->have_posts()) : $wp_query->the_post(); ?> + + while ($wp_query->have_posts()) : $wp_query->the_post(); + $output .= ' <div class="post"> - <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> + <h2><a href="'.apply_filters('the_permalink', get_permalink()).'">'.get_the_title().'</a></h2> - <small><?php the_time('F jS, Y'); ?></small> + <small>'.apply_filters('the_time', get_the_time( 'F jS, Y' ), 'F jS, Y').'</small> <div class="entry"> - <?php the_content(); ?> + '.str_replace(']]>', ']]>', apply_filters('the_content', get_the_content())).' </div> - <p class="postmetadata">Posted in <?php the_category(', '); ?></p> - - </div> + </div>'; - <?php endwhile; ?> + endwhile; + $output .= ' <div class="navigation"> - <div class="alignleft"><?php previous_posts_link('« Previous') ?></div> - <div class="alignright"><?php next_posts_link('More »') ?></div> - </div> + <div class="alignleft">'._adjacent_post_link('« Previous', '%title', false, '', true).'</div> + <div class="alignright">'._adjacent_post_link('More »', '%title', false, '', false).'</div> + </div>'; - <?php $wp_query = null; $wp_query = $temp; + $wp_query = null; $wp_query = $temp; else: @@ -73,6 +75,37 @@ endif; + return $output; +} + + +// import from wp-includes/link-template.php +function _adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { + if ( $previous && is_attachment() ) + $post = & get_post($GLOBALS['post']->post_parent); + else + $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous); + + if ( !$post ) + return; + + $title = $post->post_title; + + if ( empty($post->post_title) ) + $title = $previous ? __('Previous Post') : __('Next Post'); + + $title = apply_filters('the_title', $title, $post); + $date = mysql2date(get_option('date_format'), $post->post_date); + + $string = '<a href="'.get_permalink($post).'">'; + $link = str_replace('%title', $title, $link); + $link = str_replace('%date', $date, $link); + $link = $string . $link . '</a>'; + + $format = str_replace('%link', $link, $format); + + $adjacent = $previous ? 'previous' : 'next'; + return apply_filters( "{$adjacent}_post_link", $format, $link ); }
Viewing 1 replies (of 1 total)