• 11-07-2009, 18:07:00
    #1
    merhaba

    arkadaşlar yeni bir tema üzerinde çalışıyorum daha doğru ilk temam olacak tek bir sorunum var o da kategori ID sini nasıl görüntülerim kod ile. temanın önemli bir yerinde lazım olacak bana.

    yani demek istediğim temanın kurulu olduğu bir blogda bir yazının içine girildiğinde o yazı hangi kategoriye ait ise o kategorinin id sini görüntülemem lazım başka bir fonksiyon için.

    yanlış anlaşılmasın kategrinin ismi değil id si

    umarım anlatabilmişimdir
  • 11-07-2009, 18:44:08
    #2
    the_category_ID('')
    ile kategori idsini çekebilirsiniz. Ben bu şekilde sorunsuz çekiyorum.
  • 11-07-2009, 21:05:50
    #3
    malesef istediğim fonksiyonu yapamadım benim yapmak istediğim yazının altında o yazının ait olduğu kategorideki diğer yazılar göstermek. bunun için lazım olan tek şey bana yazının ait olduğu kategori ID sini eklemek.
  • 11-07-2009, 21:11:49
    #4
    bende çok uğraştım php bilgisi gerektiyor
  • 11-07-2009, 21:20:31
    #5
    MyMaxi adlı üyeden alıntı: mesajı görüntüle
    malesef istediğim fonksiyonu yapamadım benim yapmak istediğim yazının altında o yazının ait olduğu kategorideki diğer yazılar göstermek. bunun için lazım olan tek şey bana yazının ait olduğu kategori ID sini eklemek.
    Aşağıdaki kod yazının bulunduğu kategoride daha önce yazılan yazıları sırası ile gösteriyor single.php dosyasına eklenecek

    $count == 5 "5" gösterilecek link sayısını

    mycontent, 15 "15" linklerin üzerine gelindiğinde görürnen açıklamadaki kelime sayısını belirler


    <?php
    $this_post = $post;
    $category = get_the_category(); $category = $category[0]; $category = $category->cat_ID;
    $posts = get_posts('numberposts=4&offset=0&orderby=post_date&order=DESC&category='.$category);
    $count = 0;
    foreach ( $posts as $post ) {
    if ( $post->ID == $this_post->ID || $count == 5) {
    unset($posts[$count]);
    }else{
    $count ++;
    }
    }
    ?>
    <?php if ( $posts ) : ?>
    <ul>
    <?php function getWords($text, $limit) {
    $array = explode(" ", $text, $limit +1);
    if(count($array) > $limit) {
    unset($array[$limit]);
    }
    return implode(" ", $array); }
    ?>
    <?php foreach ( $posts as $post ) : ?>
    <?php $mycontent = strip_tags($post->post_content);
    $excerpt = getWords($mycontent, 15);
    $a_title = $excerpt . "..."; ?>
    <li><a href="<?php the_permalink(); ?>" title="<?php echo $a_title ?>">
    <?php if ( get_the_title() ) { the_title(); } else { echo "Untitle"; } ?></a>
    <?php endforeach // $posts as $post ?>
    </ul>
    <?php endif // $posts ?>
    <?php
    $post = $this_post;
    unset($this_post);
    ?>
  • 11-07-2009, 21:23:53
    #6
    aslında kategori id sini elle girince sorun olmuyor ama diyelim 5 tane kategori var x kategorinden bir yazı da adam ama bende oraya y kategorisi id si girmişim y kategorisinin yazıları görüntüleniyor. ama o zamanda pek çekici gelmiyor kullanıcıya

    tias senin ücretsiz bir video teması var mavi bir şey adı klipree ti galiba onda vardı heralde video hangi kategoride ise onunla aynı kategorideki videolar yanda listeleniyordu.

    aşağıda işaretlediğim yerki kodlardan birismi acaba

    php bilen arkadaşlar yardımcı olabilir mi?

    kodu aşağıdaki idi galiba
    <div id="rastsingle">
    	<h2>Rastgele Klipler</h2>
    	<div id="rastlistsingle">
    	  <?php query_posts('orderby=rand&showposts=3&paged='.intval(get_query_var('paged')));  if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div id="klipcephe">
    			<div class="news-img"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><img src="<?php $values = get_post_custom_values("resim"); echo $values[0]; resim_cagir(0); ?>" width="127" height="87"></a></div>
    				<div style=" margin:0 3px 0 3px;" align="center">
    					<div class="text2" align="center"><span id="soneklenenklipadi"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?> klibi izle,klibini izle,klibi indir,izlenme: <?php $values = get_post_custom_values("views"); echo $values[0]; ?>"><?php echo substr($post->post_title, 0, 15). ".."; ?></a></span></div>
    					<div id="soneklenenklip" style=""><?php the_category(); ?></div>
    				</div>
    		</div>
    	  <?php endwhile;endif; ?>
    	  
    <!-- 200x200 adsense -->
    
    <!-- 200x200 adsense -->
    
    	  </div>
    </div>
    
    
    [COLOR="DarkRed"]<?php $this_post = $post; $category = get_the_category(); $category = $category[0]; $category = $category->cat_ID; $posts = get_posts('numberposts=2&offset=0&orderby=post_date&order=DESC&category='.$category); $count = 0; foreach ( $posts as $post ) { if ( $post->ID == $this_post->ID || $count == 5) { unset($posts[$count]); } else{ $count ++; } } ?>[/COLOR]<?php if ( $posts ) : ?>
    <div id="rastsinglealt">
    	<h2><?php the_category(); ?></h2>
    	<div id="rastlistsinglealt">
    <?php function getWords($text, $limit) { $array = explode(" ", $text, $limit +1); if(count($array) > $limit) { unset($array[$limit]); } return implode(" ", $array); } ?>
    <?php foreach ( $posts as $post ) : ?>
    <?php $mycontent = strip_tags($post->post_content); $excerpt = getWords($mycontent, 15); $a_title = $excerpt . "..."; ?>
    
    <div id="klipcephe">
    	<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><div id="rastsinglealtimg"></div></a>
    	<div style=" margin:0 3px 0 3px;" align="center">
    		<div class="text2" align="center"><span id="soneklenenklipadi"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?> klibi izle,klibini izle,klibi indir,izlenme: <?php $values = get_post_custom_values("views"); echo $values[0]; ?>"><?php echo substr($post->post_title, 0, 30). ""; ?></a></span></div>
    	</div>
    </div>
    <?php endforeach?>
    	</div>
    </div>
    <?php endif ?>
    <?php $post = $this_post; unset($this_post); ?>