<div class="singlebaslikana">Son Haberler</div> <div class="singlebaslikortaana">
<?php $recent = new WP_Query("showposts=12&cat=1"); while($recent->have_posts()) :
$recent->the_post();?>
<div class="singlehaber"> <?php if( get_post_meta($post->ID, "Thumbnail", true) ): ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<a href="<?php the_permalink() ?>" rel="bookmark">
<img src="<?php bloginfo('template_url'); ?>/images/kirita.png" alt="<?php the_title(); ?>" /></a>
<?php endif; ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark"> <?php if (strlen($post->post_title) > 50) {
echo mb_substr(the_title($before = '', $after = '', FALSE), 0, 50) . '...'; } else {
the_title();
} ?> </a></h2>
<div class="entry"> <a href="<?php the_permalink() ?>"><?php the_content_limit(70, ""); ?></a> </div> </div> <?php endwhile; ?>
</div> <div class="singlebaslikaltana"></div>
</div> Wordpress Yazı Sayfasında Değişiklik
8
●364
- 27-05-2013, 12:33:32single.php dosyasında sadece bir kategori tanımlandığı için içeriğin altında o kategoriye ait yazılar yer alıyor. Bunu içeriğin yer aldığı kategorilerdeki yazıların gösterilmesi için ne yapmalıyız? İlgili bölümün kodları aşağıda...
- 27-05-2013, 12:57:33Teşekkürler fakat benim yukarıdaki kodlara müdahale ederek bunu gerçekleştirmem lazım.zanqi adlı üyeden alıntı: mesajı görüntüle
- 27-05-2013, 13:16:08Deneyin bakalım... Verdiğim linkdeki kod bu kategoriye göre benzer yazılarzanaatkar adlı üyeden alıntı: mesajı görüntüle
<div class="singlebaslikana">Son Haberler</div> <div class="singlebaslikortaana"> <?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'=>12, // Gösterilecek benzer yazı sayısı '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(); ?> <div class="singlehaber"> <?php if( get_post_meta($post->ID, "Thumbnail", true) ): ?> <a href="<?php the_permalink() ?>" rel="bookmark"><img src="<?php echo get_post_meta($post->ID, "Thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a> <?php else: ?> <a href="<?php the_permalink() ?>" rel="bookmark"> <img src="<?php bloginfo('template_url'); ?>/images/kirita.png" alt="<?php the_title(); ?>" /></a> <?php endif; ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark"> <?php if (strlen($post->post_title) > 50) { echo mb_substr(the_title($before = '', $after = '', FALSE), 0, 50) . '...'; } else { the_title(); } ?> </a></h2> <div class="entry"> <a href="<?php the_permalink() ?>"><?php the_content_limit(70, ""); ?></a> </div> </div> <?php } echo ''; } wp_reset_query(); } ?> </div> <div class="singlebaslikaltana"></div> </div> - 27-05-2013, 15:00:25Bu kodu aynen yer değiştirdim, sidebar bozuldu. Üstelik istediğim değişiklikte olmadı maalesef.zanqi adlı üyeden alıntı: mesajı görüntüle
- 27-05-2013, 17:24:59Kodu bende sitelerimde daha önce kullanmıştım ve şimdi tekrar test ettim sağlıklı bir şekilde işini yapıyor ve benzer yazıları çekiyor.
Sidebar kayması muhtemelen div lerinizle alakalıdır. Mesela verdiğim kodların en eltındaki </div> silin deneyin.
Temanın demosu mevcut ise pm ile atın bakayım.