Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 KB | None | 0 0
  1. <?php $orig_post = $post;
  2. global $post;
  3. $categories = get_the_category($post->ID);
  4. if ($categories) {
  5. $category_ids = array();
  6. foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
  7.  
  8. $args=array(
  9. 'category__in' => $category_ids,
  10. 'post__not_in' => array($post->ID),
  11. 'posts_per_page'=> 4,
  12. 'ignore_sticky_posts'=>1
  13. );
  14.  
  15. $my_query = new wp_query( $args );
  16. if( $my_query->have_posts() ) {
  17. echo '<div id="related_posts"><h2 class="headrelated">Ostatnie wiadomości w tej samej kategorii</h2>';
  18. while( $my_query->have_posts() ) {
  19. $my_query->the_post();?>
  20.  
  21.                     <article class="col-md-3 col-sm-6 grid3 relapooscla">
  22.                         <div class="featured-thumb relaposclao">
  23.                             <?php if (has_post_thumbnail()) : ?>   
  24.                                 <a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><?php the_post_thumbnail('grid3'); ?></a>
  25.                             <?php else: ?>
  26.                                 <a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><img src="<?php echo get_template_directory_uri()."/assets/images/placeholder2.jpg"; ?>"></a>
  27.                             <?php endif; ?>
  28.                         </div>
  29.                     <div class="out-thumb relaposclat">
  30.                         <header class="entry-header">
  31.                             <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php the_title() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  32.                         </header>
  33.                     </div>
  34.                     </article>
  35. <?
  36. }
  37. echo '</div>';
  38. }
  39. }
  40. $post = $orig_post;
  41. wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement