Wordpress
.  1, 2
    ~
Advanced Hosters -

DK +
wordpress
: 18.06.2008
: 2425
# : 12, 2011 7:46 pm
,

Codd
: 13.01.2011
: 186
# : 12, 2011 9:00 pm
, :
:
<?php
   $categories = get_the_category($post->ID);

   $category_ids = array();
   foreach($categories as $individual_category)
      $category_ids[] = $individual_category->term_id;

    $current_post_title = explode(' ', $post->post_title);

    $posts = get_posts( array(
                'category' => implode(',' , $category_ids),
            'showposts' => -1
                        ) );

                  
    $posts_relative_ids = array();


    foreach($posts as $a_post){
        $posts_relative_ids[$a_post->ID] = 0;

        foreach($current_post_title as $word){
            if( strpos($a_post->post_title,  ' ' .$word. ' ') != FALSE)
                $posts_relative_ids[$a_post->ID]++;
        }

    }
   
   unset($posts_relative_ids[$post->ID]);
    arsort($posts_relative_ids); $n = 0;
    foreach($posts_relative_ids as $id => $value){
        $posts_relative[] = $id;
      if(5 == $n++) break;
    }   
   
    $args=array(
        'post__in' => $posts_relative,
        'showposts' => 5,
        'orderby' => 'title',
        'order' => 'ASC'
   );

    $my_query = new wp_query($args);
    if( $my_query->have_posts() ) {
        echo '<ul>';
        while ($my_query->have_posts()) {
           $my_query->the_post();
        ?>
           <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
        <?php
        }
        echo '</ul>';
    }
     wp_reset_query();

?>


Taburetkin
: 25.02.2007
: 1426
Star (: 1)
# : 13, 2011 2:49 am
. DK - :mrrgreen:
    ~