Function for neighbouring posts, broken by 3.1-beta1
-
Until now I was using this neat little code snippet in order to display neighbouring posts (i.e. posts inside the same category as the current one).
It was made from code taken here:
https://forum.bytesforall.com/showthread.php?t=1491And looked like that, and did a perfect job:
<?php if (is_single( )) { $post_ID = $wp_query->posts[0]->ID; $all_cats_of_post = get_the_category($post_ID); for($i = 0; $i < sizeof($all_cats_of_post); $i++) { // dont show the cat_ID 8 and 10 $categories = array(8, 10); if(!in_array($all_cats_of_post[$i]->cat_ID, $categories)) { ?> <div id="category-posts-<?php echo $all_cats_of_post[$i]->cat_ID; ?>" class="post-categories"> <h3><a href="<?php bloginfo('url'); ?>/?cat=<?php echo $all_cats_of_post[$i]->cat_ID; ?>"><?php echo $all_cats_of_post[$i]->cat_name; ?></a></h3> <ul class="article-list"> <?php global $post; $cat_posts = query_posts(array( 'category__in' => array($all_cats_of_post[$i]->cat_ID), //'tag_slug__in' => tag1+tag2, 'orderby'=>date, 'posts_per_page'=>5, 'order'=>DESC, )); foreach($cat_posts as $post) : ?> <li><a href="<?php the_permalink(); ?>" class="post-<?php echo $post->ID ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> </div> <?php } ?> <?php } ?> <?php } ?>
I’m running now this template on a 3.1-beta1 test site, and I notice that this snipped doesn’t output anything at all. It doesn’t give any error message either.
The resulting HTML code from the function above:
<div id="category-posts-" class="post-categories"> <h3><a href="https://example.com/?cat="></a></h3> <ul class="article-list"> </ul> </div>
Any idea what’s going on? An unpatched 3.1-beta bug, or a deprecated function?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Function for neighbouring posts, broken by 3.1-beta1’ is closed to new replies.