是否可以在页面上设置一个部分,显示来自4个不同类别帖子的2段摘录,包括它们的特色图片?
到目前为止,我所拥有的只是:
<?php query_posts("showposts=2&cat=11,12,13,14"); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_excerpt(); ?>
<?php featured-image(); ?>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
但我不确定它是否会显示4 x 2个摘要,每个摘要中都有一个特色图片?
我的自定义类别添加如下:
function event_post_example() {
register_post_type( \'event_type\',
array(
\'labels\' => array(
\'name\' => __(\'Events Posts\', \'baretheme\'),
\'singular_name\' => __(\'Event Post\', \'baretheme\'),
\'all_items\' => __(\'All Event Posts\', \'baretheme\'),
\'add_new\' => __(\'Add New Event Post\', \'baretheme\'),
\'add_new_item\' => __(\'Add New Event Type\', \'baretheme\'),
\'edit\' => __( \'Edit\', \'baretheme\' ),
\'edit_item\' => __(\'Edit Post Types\', \'baretheme\'),
\'new_item\' => __(\'New Post Type\', \'baretheme\'),
\'view_item\' => __(\'View Post Type\', \'baretheme\'),
\'search_items\' => __(\'Search Post Type\', \'baretheme\'),
\'not_found\' => __(\'Nothing found in the Database.\', \'baretheme\'),
\'not_found_in_trash\' => __(\'Nothing found in Trash\', \'baretheme\'),
\'parent_item_colon\' => \'\'
), /* end of arrays */
\'description\' => __( \'This is the example event post type\', \'baretheme\' ), /* Custom Type Description */
\'public\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'show_ui\' => true,
\'query_var\' => true,
\'menu_position\' => 9,
\'menu_icon\' => get_stylesheet_directory_uri() . \'/library/images/custom-post-icon.png\',
\'rewrite\' => array( \'slug\' => \'event_type\', \'with_front\' => false ),
\'has_archive\' => \'event_type\',
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'trackbacks\', \'custom-fields\', \'comments\', \'revisions\', \'sticky\')
) /* end of options */
); /* end of register post type */
register_taxonomy( \'event_cat\',\'event_type\',
array(
\'labels\' => array(
\'name\' => __( \'Event Categories\', \'baretheme\' ),
\'singular_name\' => __( \'Event Category\', \'baretheme\' ),
\'search_items\' => __( \'Search Event Categories\', \'baretheme\' ),
\'all_items\' => __( \'All Event Categories\', \'baretheme\' ),
\'parent_item\' => __( \'Parent Event Category\', \'baretheme\' ),
\'parent_item_colon\' => __( \'Parent Event Category:\', \'baretheme\' ),
\'edit_item\' => __( \'Edit Event Category\', \'baretheme\' ),
\'update_item\' => __( \'Update Event Category\', \'baretheme\' ),
\'add_new_item\' => __( \'Add New Event Category\', \'baretheme\' ),
\'new_item_name\' => __( \'New Event Category Name\', \'baretheme\' )
),
\'hierarchical\' => true,
\'show_admin_column\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'event-slug\' ),
)
);
register_taxonomy( \'event_tag\',\'event_type\',
array(
\'labels\' => array(
\'name\' => __( \'Event Tags\', \'baretheme\' ),
\'singular_name\' => __( \'Event Tag\', \'baretheme\' ),
\'search_items\' => __( \'Search Event Tags\', \'baretheme\' ),
\'all_items\' => __( \'All Event Tags\', \'baretheme\' ),
\'parent_item\' => __( \'Parent Event Tag\', \'baretheme\' ),
\'parent_item_colon\' => __( \'Parent Event Tag:\', \'baretheme\' ),
\'edit_item\' => __( \'Edit Event Tag\', \'baretheme\' ),
\'update_item\' => __( \'Update Event Tag\', \'baretheme\' ),
\'add_new_item\' => __( \'Add New Event Tag\', \'baretheme\' ),
\'new_item_name\' => __( \'New Event Tag Name\', \'baretheme\' )
),
\'hierarchical\' => false,
\'show_admin_column\' => true,
\'show_ui\' => true,
\'query_var\' => true,
)
);
}
add_action( \'init\', \'event_post_example\');