Suporte » Temas e templates » Problemas com loop e Wp_Query
Problemas com loop e Wp_Query
-
Boa tarde, sou novo aqui neste fórum. Estou desenvolvendo um site e preciso que os posts sejam exibidos de acordo com os valores que inseri no campo personalizado que chamei de “peso” cujos valores vão de 0 a 10. Os posts com valores mais altos deveriam ser exibidos no topo. Isso até acontece nas categorias, mas quando utilizo a busca os posts com valores maiores também aparecem no topo, mesmo nem possuindo nenhum valor correspondente a busca. Segue o loop:
<?php if ( have_posts() ) : ?> <?php $anuncio = new WP_Query( array ('orderby' => 'meta_value_num', 'meta_key' => 'peso', 'paged' => get_query_var( 'paged' ), 'order' => 'DESC' ) ); ?> <div id="loop" class="list clear"> <?php while ( $anuncio->have_posts() ) : $anuncio->the_post(); ?> <div class="post clear" id="post_<?php the_ID(); ?>"> <?php if ( has_post_thumbnail() ) :?> <a href="<?php the_permalink() ?>" class="thumb"> <?php the_post_thumbnail('thumbnail', array( 'alt' => trim(strip_tags( $post->post_title )), 'title' => trim(strip_tags( $post->post_title )), )); ?> </a> <?php endif; ?> <h2><a href="<?php the_permalink() ?>"> <?php the_title(); ?> </a></h2> <div class="post-category">em <?php the_category(' / '); ?></div> <div class="post-intro"> <strong>Telefone:</strong> <?php $values = get_post_custom_values("telefone"); echo $values[0]; ?><br /> <strong>Endereço:</strong> <?php $values = get_post_custom_values("endereco"); echo $values[0]; ?><br /> <strong>Site:</strong> <a href="http://<?php $values = get_post_custom_values("site"); echo $values[0]; ?>" target="_blank"> <?php $values = get_post_custom_values("site"); echo $values[0]; ?></a> </div> </div> <?php endwhile; ?> <?php wp_reset_postdata(); ?> </div> <?php endif; ?>
Se alguém poder me ajudar, já procurei em vários lugares, já usei até query_posts e obtenho o mesmo resultado.
- O tópico ‘Problemas com loop e Wp_Query’ está fechado a novas respostas.