Ciao a tutti,
ho scritto in una pagina Wordpress questo listato, per non far apparire in una griglia di immagini quelle relative alla pagina chi siamo.
Il listato funziona, ma mi da un warning: ": Invalid argument supplied for foreach() in on line"
C'è qualcosa che non va?
codice:<ul style="margin-top:40px;" id="portfolio-list" > <?php $loop = new WP_Query( array( 'post_type' => 'photos','posts_per_page' => -1 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php $ok2 = false; $terms = get_the_terms( get_the_ID(), 'gallery' ); foreach($terms as $term) { if($term->slug == "chi-siamo"){ $ok2 = true; } } if($ok2 == false) { ?> <li class=" item <?php foreach ($terms as $term) { echo strtolower(preg_replace('/\s+/', '-', $term->name)). ' ';} ?> "> <div class="itemeta"> <h3> <?php the_title();?> </h3> </div> [img]<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php echo get_image_url()?>&h=200&w=220&zc=1[/img]" alt="" /> <?php } endwhile; ?> [/list]

Rispondi quotando
