Merhaba, responsive temasını kullanıyorum. okuma ayarlarından her yazı için özet göster dediğim halde; anasayfadaki yazılarda 4-5 tane resmin hepsi gözüküyor. bunu nasıl 1 resim ile sınırlandırabilirim?
kategori ve arşiv sayfalarında bu sorun yok, ama resim de yok.(öne çıkarılan belirleyince gözüküyor.)
otomatik olarak ilk resim göstermeyi nasıl yapabilirim? (kategori ve anasayfada)
edit:kimseden ses çıkmayınca çözümü kendim uğraşarak buldum. ilk img bulan fonksiyon:
function get_post_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = preg_replace('#-(\d+)x(\d+).(\w{3})#i','.$3',$matches[1][0]);
$first_img = str_replace(array('.jpg','.gif','.png'),array('-150x150.jpg','-150x150.gif','-150x150.png'),$first_img);
if(empty($first_img)){ //Defines a default image
$img_dir = get_bloginfo('template_directory');
$first_img = $img_dir . '/images/post-default.jpg';
}
return $first_img;
}kullanım:
index yada home dosyasındaki döngüyü bununla değiştim:
<div class="post-entry">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<img class="alignleft wp-post-image" src="<?php echo get_post_image(); ?>"/>
</a>
<?php the_excerpt(); ?>
<?php wp_link_pages( array( 'before' => '<div class="pagination">' . __( 'Pages:', 'responsive' ), 'after' => '</div>' ) ); ?>
</div>