当然,你可以。你必须先创建新的帖子类型。你可以在functions.php
:
add_action( \'init\', \'register_cpt_YourPostType\' );
function register_cpt_YourPostType() {
$labels = array(
\'name\' => _x( \'YourPostType\', \'your-post-type\' ),
\'singular_name\' => _x( \'YourPostType\', \'your-post-type\' ),
),
\'menu_name\' => _x( \'YourPostType\', \'your-post-type\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => false,
\'description\' => \'Your description\',
\'supports\' => array( \'title\', \'editor\', \'thumbnail\' ),
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'slug\' => \'your-post-type\',
\'show_in_nav_menus\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'has_archive\' => true,
\'query_var\' => true,
\'can_export\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\'
);
register_post_type( \'your-post-type\', $args );
}
/**********************************************************************/
然后,在每个模板中使用所需的帖子类型:
$type = \'your-post-type\';
$args = array (
\'post_type\' => $type,
\'post_status\' => \'publish\',
\'posts_per_page\' => -1,
\'ignore_sticky_posts\'=> 1
);
$temp = $wp_query; // assign ordinal query to temp variable for later use
$wp_query = null;
$wp_query = new WP_Query($args);
if($wp_query->have_posts()) {
while ( $wp_query->have_posts() ) : $wp_query->the_post();
...