获取错误帖子的自定义帖子的每年存档
我得到了wp\\u get\\u the\\u archives()来列出我的帖子的年份,但即使url没有问题,年份归档中显示的帖子也会根据我每年的帖子数量给出最后一篇帖子。
例如,我2008年有3篇文章,那一年的档案只会显示3篇文章,但仅显示最后三篇(2021 2篇,2016年1篇)。如果我有2016年的1篇文章,档案将显示一篇文章,但这只是2021的最后一篇。等等我做错了什么?
我的职能。php文件
<?php
function recursos_ah6studio(){
wp_enqueue_style(\'bootstrap\', get_theme_file_uri(\'/css/bootstrap.min.css\'));
wp_enqueue_style(\'slick\', get_theme_file_uri(\'/slick/slick.css\'));
wp_enqueue_style(\'slick-theme\', get_theme_file_uri(\'/slick/slick-theme.css\'));
wp_enqueue_style(\'magnific-popup\', get_theme_file_uri(\'/magnific-popup/magnific-popup.css\'));
wp_enqueue_style(\'font-awesome\', get_theme_file_uri(\'/fontawesome-5.5/css/all.min.css\'));
wp_enqueue_style(\'estilo_ah6studio\', get_stylesheet_uri());
/*wp_enqueue_script(\'mainJS\', get_theme_file_uri(\'/js/main_js.js\'), NULL, \'1.0\', true); */
wp_enqueue_script(\'jquery\', get_theme_file_uri(\'/js/jquery-3.5.1.min.js\'), NULL, \'1.0\', true);
wp_enqueue_script(\'popper\', get_theme_file_uri(\'/js/popper.min.js\'), NULL, \'1.0\', true);
wp_enqueue_script(\'boostrap\', get_theme_file_uri(\'/js/bootstrap.min.js\'), NULL, \'1.0\', true);
wp_enqueue_script(\'slickJS\', get_theme_file_uri(\'/slick/slick.min.js\'), NULL, \'1.0\', true);
wp_enqueue_script(\'magnific-popup\', get_theme_file_uri(\'/magnific-popup/jquery.magnific-popup.min.js\'), NULL, \'1.0\', true);
wp_enqueue_script(\'easingJS\', get_theme_file_uri(\'/js/easing.min.js\'), NULL, \'1.0\', true);
wp_enqueue_script(\'singlePageJS\', get_theme_file_uri(\'/js/jquery.singlePageNav.min.js\'), NULL, \'1.0\', true);
wp_enqueue_script(\'tool-tip\', get_theme_file_uri(\'/js/tooltip.js\'), NULL, \'1.0\', true);
}
add_action(\'wp_enqueue_scripts\', \'recursos_ah6studio\');
function mytheme_enqueue_front_page_scripts() {
if( is_front_page() )
{
wp_enqueue_script(\'bkcground-random\', get_theme_file_uri(\'/js/background_random.js\'), NULL, \'1.0\', true);
}
}
add_action( \'wp_enqueue_scripts\', \'mytheme_enqueue_front_page_scripts\' );
function ourWidgetInit(){
register_sidebar( array (
\'name\' => \'Sidebar\',
\'id\' => \'sidebar1\',
));
register_sidebar( array (
\'name\' => \'Desplegable\',
\'id\' => \'desplega1\',
\'before_widget\'=>\'<div class="widget-item">\',
\'after_widget\'=> \'</div>\',
\'before_title\'=>\'<h6 class="category_title">\',
\'after_title\'=>\'</h6>\',
));
}
add_action(\'widgets_init\', \'ourWidgetInit\');
//Añadir el thumbnail//
function ah6studio_setup() {
add_theme_support(\'post-thumbnails\');
add_theme_support(\'title-tag\');
}
add_action(\'after_setup_theme\',\'ah6studio_setup\');
我的插件文件ah6\\U postypes。php
<?php
function ah6_papers() {
register_post_type(\'papers\', array(
\'has_archive\'=> true,
\'public\'=> true,
\'posts_per_page\' => -1,
\'labels\'=> array(
\'name\'=>\'Papers\',
\'add_new\'=> \'Agregar un Paper\',
\'edit_item\'=>\'Editar un Paper\',
\'all_items\'=>\'Todos los Papers\',
\'singular_name\'=>\'Paper\'
),
\'taxonomies\' => array(\'temas\'),
\'menu_icon\'=> \'dashicons-media-text\',
));
}
add_action(\'init\', \'ah6_papers\');
function papers_categories() {
//Taxonomía: TEMAS
//Traducción para el backend
$labels = array(
\'name\' => _x( \'Temas\', \'taxonomy general name\' ),
\'singular_name\' => _( \'Tema\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Buscar tema\' ),
\'all_items\' => __( \'Todos los temas\' ),
\'parent_item\' => __( \'Tema padre\' ),
\'parent_item_colon\' => __( \'Tema padre:\' ),
\'edit_item\' => __( \'Editar tema\' ),
\'update_item\' => __( \'Actualizar tema\' ),
\'add_new_item\' => __( \'Añadir nuevo tema\' ),
\'new_item_name\' => __( \'Nombre del nuevo tema\' ),
\'menu_name\' => __( \'Temas\' ),
);
// Registrando la taxonomía
register_taxonomy(\'temas\',array(\'papers\'), array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_in_rest\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'temas\' ),
));
//Taxonomía: TERRITORIOS
//Traducción para el backend
$labels = array(
\'name\' => _x( \'Territorios\', \'taxonomy general name\' ),
\'singular_name\' => _( \'Territorio\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Buscar territorio\' ),
\'all_items\' => __( \'Todos los territorios\' ),
\'parent_item\' => __( \'Territorio padre\' ),
\'parent_item_colon\' => __( \'Territorio padre:\' ),
\'edit_item\' => __( \'Editar territorio\' ),
\'update_item\' => __( \'Actualizar territorio\' ),
\'add_new_item\' => __( \'Añadir nuevo territorio\' ),
\'new_item_name\' => __( \'Nombre del nuevo territorio\' ),
\'menu_name\' => __( \'Territorios\' ),
);
// Registrando la taxonomía
register_taxonomy(\'territorios\',array(\'papers\'), array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_in_rest\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'territorios\' ),
));
}
add_action( \'init\', \'papers_categories\', 0 );