WordPress’de Benzer Yazılar Modülü Yapma ( Eklentisiz Yapma )
19 Ağustos 2018 / 13:23
Burak
Merhaba arkadaşlar WordPress üzerinden benzer yazıları göstermek istiyorsanız aşağıdaki kodu single.php de gözükmesini istediğiniz yere yapıştırmanız yeterlidir.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<?php $categories = get_the_category($post->ID); if ($categories) { $category_ids = array(); foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id; $args=array( 'category__in' => $category_ids, 'post__not_in' => array($post->ID), 'showposts'=>3, 'caller_get_posts'=>1 ); $my_query = new wp_query($args); if( $my_query->have_posts() ) { echo ''; while ($my_query->have_posts()) { $my_query->the_post(); ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <div class="category_img"> <?php the_post_thumbnail(); ?> <div class="category_title"> <?php the_title(); ?> </div> </div> </a> <?php } echo ''; } wp_reset_query(); } ?> |
Bu Yazılarıda Okuyabilirsiniz...
Bir yanıt yazın