Exibir posts apenas de determinado formato
-
Bom sabemos que o wordpress oferece a função post formats que voce escolhe o formato do post, galeria,nota… etc, certo?
Então… queria um codigo que listasse todas as postagens de uma determinada categoria de um determinado post-format.
-
Obrigado amigo.
Consegui um código que funcione também.
<?php /* POSTS NOTA */ ?> <?php $category_id = get_cat_ID(single_cat_title('', false)); $args = array( 'cat' => $category_id, 'post_type' => 'post', 'post_status' => 'publish', 'order' => 'DESC', 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-aside' ), 'operator' => 'IN', ) ) ); $status_updates = get_posts( $args ); if ( $status_updates ) : ?> <?php foreach ( $status_updates as $post ) : setup_postdata( $post ); ?> <li><a href="<?php the_permalink(); ?>" title="<?php esc_attr( the_title() ); ?>"><?php the_title(); ?></a></li> <?php endforeach; endif; ?>
Me ajudou mesmo assim! Valeu!
Amigo preciso da sua ajuda o meu codigo apresentou falhas.
Consegui desenvolver esse:
<?php $args = array( 'cat' => $cat, 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-status','post-format-gallery','post-format-aside','post-format-quote','post-format-audio'), ) ) ); ?> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> <?php endif; ?>
Mas não consigo que ele mostre apenas os post-formats que informei no campo terms e tambem gostaria que ele tivesse posts_per_page=-1 para listar todas as publicações
Consegui desenvolver com base no site que me enviou esse codigo, só que nao consigo que ele apareça todas os posts (posts_per_page=-1) o que devo fazer?
<?php // The Args $args = array( 'cat' => $cat, 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-quote','post-format-audio','post-format-gallery','post-format-image','post-format-link','post-format-video') ) ) ); // The Query query_posts( $args ); // The Loop while ( have_posts() ) : the_post(); echo '<li>'; the_title(); echo '</li>'; endwhile; // Reset Query wp_reset_query(); ?>
depois de quebrar bastante a cabeça consegui o código:
<?php $args = array( 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-status', 'post-format-aside', 'post-format-gallery', 'post-format-quote', 'post-format-audio'), ) ) ); ?> <?php query_posts( '&orderby=title&order=asc&posts_per_page=-1&cat=' . $cat . '&args=' . $args );?> <ol> <?php while ( have_posts() ) : the_post(); ?> <li><a href="<?php the_permalink() ?>"> <?php the_title(); ?> </a></li> <?php endwhile; ?> </ol> <?php wp_reset_query(); ?>
Mas não estou conseguindo aplicar esses argumentos:
<?php query_posts( '&orderby=title&order=asc&posts_per_page=-1&cat=' . $cat . '&args=' . $args );?>
qual a forma correta de aplicar?
Não percebo porque é que os argumentos não estão todos no array, i.e.
<?php $args = array( 'cat' => $cat, 'posts_per_page' => -1, 'order' => 'asc', 'order_by' => 'title', 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-status', 'post-format-aside', 'post-format-gallery', 'post-format-quote', 'post-format-audio'), ) ) ); query_posts( $args ); // etc... ?>
- O tópico ‘Exibir posts apenas de determinado formato’ está fechado a novas respostas.