我试图从显示4篇最新帖子的页面模板循环中排除所有帖子格式,但标准格式除外。由于某种原因,我无法使查询正常工作。
这是我的页面模板
global $paged, $wp_query, $wp;
$args = wp_parse_args($wp->matched_query);
if ( !empty ( $args[\'paged\'] ) ) {
$wp_query->set(\'paged\', $args[\'paged\']);
$paged = $args[\'paged\'];
}
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
query_posts(\'cat=0&posts_per_page=4&paged=\'.$paged); //set your own query here
get_template_part( \'loop\', \'portfolio\' );
wp_reset_query();
这是回路
<?php $num_cols = 4; // set the number of columns here
for ( $i=1 ; $i <= $num_cols; $i++ ) :
echo \'<div class="column col-\' . $i . \'" >\';
$counter = $num_cols + 1 - $i; ?>
<?php while (have_posts()) : the_post();
if( $counter%$num_cols == 0 ) :
// begin of core posts output ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
POST STUFF
<?php //end of posts output
endif; $counter++;
endwhile;
rewind_posts();
echo \'</div>\'; //closes the column div
endfor; ?>
<?php if ( $wp_query->max_num_pages > 1 || get_query_var(\'page\')) : ?>
<?php twentytwelve_content_nav( \'nav-below\' ); ?>
<?php endif;
wp_reset_query(); ?>
这就是我一直在努力解决的问题
$args = array(
\'tax_query\' => array(
array(
\'taxonomy\' => \'post_format\',
\'field\' => \'slug\',
\'terms\' => array( \'post-format-aside\', \'post-format-image\' ),
\'operator\' => \'NOT IN\'
)
)
);
$query = new WP_Query( $args );