<?php
query_posts("cat=2&orderby=rand&posts_per_page=6");
while(have_posts()) : the_post(); ?>Sorunu çözdüm bu kod ile teşekkürler
hocam yalnız burada 2. kategorinin yazılarını çekiyorsunuz ve sayfa başına 6 tane gösteriyorsunuz.
Ayrıca bu şekilde index.php de listelenen (Arama sonuçlar, kategori listesi, arşiv listesi vs. vs. "kendilerine ait archive.php" gibi bir sayfası yoksa) de etkilenecektir.
Doğrusu şudur:
<?php
// The Query
$the_query = new WP_Query( 'category_name=movies' );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
?>$the_query->have_posts(); ile tetiklersiniz.
wp_reset_postdata(); ile resetlersiniz. Sadece o kod bloğu etkilenir.