• 30-07-2013, 05:17:21
    #1
    Reveloper
    Merhaba,

    Örnek bir WP döngüsü varsa yazabilirmisiniz.

    istediğim şey:

    WHILE ile yazıları bassın, WHERE ile özel alan=X kontrolü yapsın?

    Şunun wp hali işte
    <?php
    $get_news = mysql_query("SELECT * FROM news ORDER BY id ASC LIMIT 6");
    while ( $list_news = mysql_fetch_array($get_news) ){ // while
    
    echo $list_news["news_title"];
    
    }
    ?>
  • 30-07-2013, 19:55:29
    #2
    Reveloper
    yaptım belki ihtiyacı olan olur:
    			<?php
    			if (have_posts()) :  while (have_posts()) : the_post();
    			$cek=get_post_meta($post->ID, "anasayfa", true); if($cek==1):
    			?>
    				<div class="product">
    					<div class="product-photo"><a href="<?php the_permalink(); ?>">
    					<img src="<?php echo get_post_meta($post->ID, 'resim',true) ?>" alt="<?php the_title(); ?>" class="product-photo" /></a>
    					</div>
    						<a href="<?php the_permalink(); ?>"><h1><?php the_title(); ?></a></h1>
    					<div class="price">Fiyatı: <?php echo get_post_meta($post->ID, 'fiyat',true) ?>TL</div>
    						<div class="buttons">
    							<a href="<?php the_permalink(); ?>" class="details">Detaylar</a>
    							<a href="<?php echo get_post_meta($post->ID, 'siparis',true) ?>" class="onbasket">Siparis Ver</a>
    						</div>
    				</div>			<?php				 endif; endwhile; else : endif;			?>
  • 30-07-2013, 20:16:46
    #3
    Böyle yaparsan sayfalama sisteminde sorun oluşur. Diyelim ki son yazdığın 5 yazıda anasayfa özel alanı yok, bu durumda ana sayfanda normalde 10 yazı gösteriliyorsa bu durumda 5 yazı gösterilmiş olur.
    Problemin çözümü
    if (have_posts() ile başlayan satırın üstüne aşağıdaki kodu eklersen istediğin olacaktır.

    query_posts($query_string . '&meta_key=anasayfa&meta_value=1');
    Kod meta anahtarı anasayfa ve değeri 1 olanları döngünün içerisine alır.