是否要多个自定义网站帖子?您告诉我您已经为您的网站创建了一个自定义帖子。别担心。现在我会帮你解决你的问题
首先,在您的和粘贴功能上创建另一个自定义帖子。php或自定义帖子。php文件。现在我将创建自定义帖子Movie 类型。你可以改变它Movie 将其替换为自定义帖子类型名称。
function custom_post_type() {
// Set UI labels for Custom Post Type
$labels = array(
\'name\' => _x( \'Movies\', \'Post Type General Name\' ),
\'singular_name\' => _x( \'Movie\', \'Post Type Singular Name\'),
\'menu_name\' => __( \'Movies\'),
\'parent_item_colon\' => __( \'Parent Movie\' ),
\'all_items\' => __( \'All Movies\'),
\'view_item\' => __( \'View Movie\'),
\'add_new_item\' => __( \'Add New Movie\'),
\'add_new\' => __( \'Add New\' ),
\'edit_item\' => __( \'Edit Movie\' ),
\'update_item\' => __( \'Update Movie\' ),
\'search_items\' => __( \'Search Movie\'),
\'not_found\' => __( \'Not Found\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\'),
);
// Set other options for Custom Post Type
$args = array(
\'label\' => __( \'movies\' ),
\'description\' => __( \'Movie news and reviews\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'author\', \'thumbnail\', \'comments\', \'revisions\', \'custom-fields\', ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
// This is where we add taxonomies to our CPT
\'taxonomies\' => array( \'category\' ),
);
// Registering your Custom Post Type
register_post_type( \'movies\', $args );
}
add_action( \'init\', \'custom_post_type\', 0 );
Displaying Multiple Post Types
<?php
$args = array( \'post_type\' => \'movies\', \'posts_per_page\' => 10 );
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( \'Sorry, no posts matched your criteria.\' ); ?></p>
<?php endif; ?>