Need help with related posts php (1 post)

  1. heleh
    Posted 2 years ago #

    I'm using this code to show related posts by category.

    $categories = get_the_category($post->ID);
    if ($categories) {
    	$category_ids = array();
    	foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
    		'category__in' => $category_ids,
    		'post__not_in' => array($post->ID),
    		'showposts'=>5, // Number of related posts that will be shown.
    	$my_query = new wp_query($args);
    	if( $my_query->have_posts() ) {
    		echo '<h3>See also</h3><ul>';
    		while ($my_query->have_posts()) {
    			<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    		echo '</ul>';

    The problem is that it shows also the post I'm currently viewing. How to change this code to make it show only other posts in that category?

    And another problem:
    I know how to change font size of that same recent posts widget but not sure how to change line height. Tried hours to find it from css but without results.


Topic Closed

This topic has been closed to new replies.

About this Topic