以下代码是自定义帖子类型:
add_action( \'init\', \'wpt_technology_posttype\' );
function wpt_technology_posttype() {
register_post_type( \'technology\',
array(
\'labels\' => array(
\'name\' => __( \'Technology Providers List\' ),
\'singular_name\' => __( \'Technology\' ),
\'add_new\' => __( \'Add Techonology Provider\' ),
\'add_new_item\' => __( \'Add New Technology\' ),
\'edit_item\' => __( \'Edit Technology\' ),
\'new_item\' => __( \'Add New Technology\' ),
\'view_item\' => __( \'View Technology\' ),
\'search_items\' => __( \'Search Technology\' ),
\'not_found\' => __( \'No News found\' ),
\'not_found_in_trash\' => __( \'No Technology found in trash\' )
),
\'public\' => true,
\'has_archive\' =>\'true\',
\'hierarchical\' => true,
\'supports\' => array( \'title\',\'thumbnail\',\'editor\', \'comments\' ),
\'capability_type\' => \'post\',
\'rewrite\' => array("slug" => "techno_type"), // Permalinks format
\'menu_position\' => 22,
)
);
register_taxonomy(\'techno_type\', \'technology\',
array(\'hierarchical\' => true, \'label\' => \'Add New Technology\', \'query_var\' => true, \'rewrite\' => true));
}
我创建了页面名称归档技术。php。我写了脚本,但找不到页面。如何在存档页面中显示帖子。在
functions.php
:
function custom_post_archive( $query ){
if ( is_post_type_archive(\'technology\') ) {
include \'archive-technology.php\';
}
}
add_action(\'pre_get_posts\',\'custom_post_archive\');