• 08-07-2014, 22:56:40
    #1
    Merhaba,
    Sadece ana/üst kategorileri rastgele göstermek istiyorum ancak bi' türlü başaramadım. Nasıl yapabileceğim konusunda bi' fikir arıyorum.
  • 08-07-2014, 23:10:53
    #2
    <?php
    //display random sorted list of terms in a given taxonomy
    $counter = 0;
    $max = 5; //number of categories to display
    $taxonomy = 'category';
    $terms = get_terms($taxonomy);
    shuffle ($terms);
    //echo 'shuffled';
    if ($terms) {
    	foreach($terms as $term) {
    		$counter++;
    		if ($counter <= $max) {
    	  	echo '<p><a href="' . get_category_link( $term->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a></p> ';
    	 	}
    	}
    }
    ?>
  • 09-07-2014, 00:50:27
    #3
    altf4 adlı üyeden alıntı: mesajı görüntüle
    <?php
    //display random sorted list of terms in a given taxonomy
    $counter = 0;
    $max = 5; //number of categories to display
    $taxonomy = 'category';
    $terms = get_terms($taxonomy);
    shuffle ($terms);
    //echo 'shuffled';
    if ($terms) {
    	foreach($terms as $term) {
    		$counter++;
    		if ($counter <= $max) {
    	  	echo '<p><a href="' . get_category_link( $term->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a></p> ';
    	 	}
    	}
    }
    ?>
    bu kod alt kategorileri de göstermekte.
  • 10-07-2014, 08:33:16
    #4
    Halen sorunu çözemedim :/