Merhaba arkadaslar,
Wordpresste konularima title olarak konularin icindeki aciklamalari koymak istiyorum. Ama nasil yapabilirim ? Yardim edebilecek bir arkadas varmi ?
<li><a href="<?php the_permalink() ?>" title="Permanent link to <?php if ( get_the_title() ){ the_title(); }else{ echo "Untitled"; } ?>"><?php if ( get_the_title() ){ the_title(); }else{ echo "Untitled"; } ?></a></li>
Bunu yapabildim ama daha ilerisini beceremedim.
Yardimlarinizi bekliyorum.
bol kazancli gunler.
Wordpresste konu aciklamalarini konu title ina nasil cekebilirim?
8
●372
- 27-07-2010, 16:35:04
- 27-07-2010, 18:19:55Daha ayrintili anlatayim. Kategori listesi yaptim. Herhangi bir kategoriye girince koseye bolum listesi var. Onlarin linklerindeki title="burasi" kismina bolumlerin aciklamalarini koymak istiyorum. Ama beceremedim. Onu nasil yaparim.
- 27-07-2010, 19:13:44anladığım kadarı ile kategorilerin yazıları sadece başlıklardan oluşuyor başlıkların titlesinde yazının özeti görünecek
öyle ise temanın functions.php dosyasına aşağıdaki kodu ekleyin
function post_limit($max_char, $more_link_text = '', $stripteaser = 0, $more_file = '') { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $content = strip_tags($content); if (strlen($_GET['p']) > 0) { echo ""; echo $content; echo "..."; } else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) { $content = substr($content, 0, $espacio); $content = $content; echo ""; echo $content; echo "..."; } else { echo ""; echo $content; } }
başlıklar için aşağıdaki kodu kullanın
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php post_limit('100'); ?>"><?php the_title(); ?></a> 100 harf sayısını belirler - 27-07-2010, 20:44:29Titlelar hep ayni cikiyor. Mesela bir konuya girince butun titlelar o konunun aciklamasini aliyor. Kullandigim kodlar bunlar. Bunlardami sorun var sizce ?
<?php
$this_post = $post;
$category = get_the_category(); $category = $category[0]; $category = $category->cat_ID;
$posts = get_posts('numberposts=250&offset=0&orderby=post_d ate&order=DESC&category='.$category);
$count = 0;
foreach ( $posts as $post ) {
if ( $post->ID == $this_post->ID || $count == 5) {
unset($posts[$count]);
}else{
$count ++;
}
}
?>
<?php
foreach ( $posts as $post ) :
?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php post_limit('100'); ?>"><?php the_title(); ?></a>
<?php endforeach // $posts as $post ?> - 27-07-2010, 21:28:21kullandığım kodlar standart <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> döngüsünde çalışıyor sizin temanızdada aynı sistem vardır vardır index.php ben ana sayfadaki yazıların başlıklarında kullanmıştım
fakat siniz kodlarınız ile uyumlu değilmiş ilk verdiğim kodlar sidebarda işe yaramıyor
sidebar uyumlu olanı;
<?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); ?>
bu kodu direkt sidebar.php dosyanıya ekleyin $mycontent, 15 özet kelime limiti için kullanılıyor 15 değerini istediğiniz şekilde ayarlarsınız numberposts=4 gösterilecek bağlantı sayısıdır
lokalde denedim her yazının kendi özetini titlede görüntülüyor
bu kod yazının kategorisindeki diğer yazıları listeler bir ara yazı sayfasında benzer yazılar olarak kullanıyordum sidebardada çalışıyormuş öğrenmiş olduk