.ic-konu{ padding: 15px; background-color: #f7f7f7; }
.konu-gorsel, .konu{ float: left; }
.konu-gorsel{ width: 15%; text-align: right; }
.konu{ width: 85%; box-sizing: border-box; padding-left: 15px; }
.konu-gorsel img{ max-width: 100% !important; height: auto !important; }
.baslik{ font-weight: bold; }
.baslik a{ color: red; text-decoration: none; }
.ozet{ margin: 10px 0; }
.ayrinti{ font-size: 13px; font-style: italic; }
functions.php dosyasına
function onerilen_konu(){
global $post;
$orjinal_yazi = $post;
$etiketler = wp_get_post_tags($post->ID);
if($etiketler){
$etiket_idleri = array();
foreach($etiketler as $etiket) $etiket_idleri[] = $etiket->term_id;
$args = array(
'tag__in' => $etiket_idleri,
'post__not_in' => array($post->ID),
'posts_per_page' => 1, // kaç konu gösterilsin?
);
$sorgu = new wp_query($args);
while($sorgu->have_posts()){
$sorgu->the_post();
$konu = '';
if(has_post_thumbnail()): $konu .= ''.get_the_post_thumbnail().''; endif;
$konu .= ''.get_the_excerpt().''.get_the_author().' • '.get_the_category_list(', ').' • '.get_the_date(get_option('date_formatss')).'';
$konu .= '';
return $konu;
}
}
$post = $orjinal_yazi;
wp_reset_query();
}
add_shortcode('konu','onerilen_konu');
Kullanımı
Konu içerisinde önerilen konuyu göstermek istediğiniz yere [konu] yazıyorsunuz, etiketlere göre alaklı bir konu bulunursa gösteriliyor.