Advertisement
Konark

Untitled

Sep 20th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <h4>Читайте также:</h4>
  2.  
  3.  
  4.  
  5. <?php
  6.  
  7.  
  8.  
  9. $categories = get_the_category($post->ID);
  10.  
  11.  
  12.  
  13. if ($categories) {
  14.  
  15.  
  16.  
  17. $category_ids = array();
  18.  
  19.  
  20.  
  21. foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
  22.  
  23.  
  24.  
  25. $args=array(
  26.  
  27.  
  28.  
  29. 'category__in' => $category_ids,
  30.  
  31.  
  32.  
  33. 'post__not_in' => array($post->ID),
  34.  
  35.  
  36.  
  37. 'showposts'=>5,
  38.  
  39.  
  40.  
  41. 'caller_get_posts'=>1);
  42.  
  43.  
  44.  
  45. $my_query = new wp_query($args);
  46.  
  47.  
  48.  
  49. if( $my_query->have_posts() ) {
  50.  
  51.  
  52.  
  53. echo '<ul>';
  54.  
  55.  
  56.  
  57. while ($my_query->have_posts()) {
  58.  
  59.  
  60.  
  61. $my_query->the_post();
  62.  
  63.  
  64.  
  65. ?>
  66.  
  67.  
  68.  
  69. <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  70.  
  71.  
  72.  
  73. <?php
  74.  
  75.  
  76.  
  77. }
  78.  
  79.  
  80.  
  81. echo '</ul>';
  82.  
  83.  
  84.  
  85. }
  86.  
  87.  
  88.  
  89. wp_reset_query();
  90.  
  91.  
  92.  
  93. }
  94.  
  95.  
  96.  
  97. ?></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement