Onur89TR adlı üyeden alıntı: mesajı görüntüle
Kod bu. İyi kafa yorduğumu söyleyebilirim.
<?php $katadlari = array("111","Genel","222"); // BURAYA KATEGORİ İSİMLERİNİ TIRNAKLAR VE VİRGÜLLER EŞLİĞİNDE, DİZİ OLARAK YAZIYORSUNUZ. GERİSİNİ KENDİSİ HALLEDİYOR.
for ($i=0; $i<count($katadlari); $i++) {
$katidleri[]=get_cat_ID($katadlari[$i]);
}
ShowCategories(0,$katidleri);
$katidleri = "";
function ShowCategories($parent_category,$katid) {
$categories = get_categories(array('parent' => $parent_category, 'hide_empty' => 0));
foreach ($categories as $category) {
if ((in_array($category->term_id,$katid)) && (is_array($katid))) { ?>
<ul><li><?php
echo $category->cat_name;
$args = array("cat"=>$category->term_id);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) { ?>
<ul>
<?php while ( $the_query->have_posts() ) {
$the_query->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php } ?>
</ul>
<?php wp_reset_postdata();
} else {
// yazi yok
} ?>
<?php ShowCategories($category->cat_ID,$katid); ?></li></ul>
<?php
}
}
} ?>
çok teşekkür ederim hocam, özelden mesaj gönderdim atladığım bir kısım var sanırım bakabilir misiniz