我有一个在函数中创建的自定义帖子类型。php。
function codex_custom_init() {
$labels = array(
\'name\' => \'Restaurantes\',
\'singular_name\' => \'Restaurante\',
\'add_new\' => \'Añadir Nuevo\',
\'add_new_item\' => \'Añadir Nuevo Restaurante\',
\'edit_item\' => \'Editar Restaurante\',
\'new_item\' => \'Nuevo Restaurante\',
\'all_items\' => \'Todos los Restaurantes\',
\'view_item\' => \'Ver Ver Restaurante\',
\'search_items\' => \'Buscar Restaurantes\',
\'not_found\' => \'No se encontraron restaurantes\',
\'not_found_in_trash\' => \'Restaurantes no encontrados en la Papelera\',
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Restaurantes\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'restaurante\' ),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comments\' )
);
register_post_type( \'restaurante\', $args );
}
add_action( \'init\', \'codex_custom_init\' );
我试图在存档页中显示属于此自定义帖子类型的所有项目。我有460个这种自定义帖子类型的条目。我创建了文件
archive-restaurante.php
我试图按一个名为restaurante_municipio
<?php
query_posts(
wp_parse_args(
$wp_query->query
,array(\'post_type\' => \'restaurante\',
\'posts_per_page\' => -1,
\'meta_key\' => \'restaurante_municipio\',
\'orderby\' => \'meta_value\',
\'order\' => \'ASC\')
)
);
global $wp_query;
$total_results = $wp_query->found_posts;
echo \'<p><b>Restaurantes: \'.$total_results.\'</b>\';
?>
if(have_posts() ) {
?>
...
..
.
<?php while (have_posts()) : the_post(); ?>
...
..
.
<?php endwhile; ?>
...
..
.
显示的项目数为230结果总数(460)除以2。
如果我将posts\\u per\\u页面更改为100,则显示的结果数为50。再次将post\\u per\\u页除以2。
如果我将post\\u per\\u页面更改为920,则显示的结果数再次为230。
我做错了什么?
非常感谢您的帮助。