wordpress 增加Slide页面类型
- //该函数用于增加Slide页面类型。
- add_action('init', 'slider_register');
- function slider_register() {
- $labels = array(
- 'name' => _x('幻灯片', 'post type general name'),
- 'singular_name' => _x('幻灯片列表', 'post type singular name'),
- 'add_new' => _x('新建', 'slider item'),
- 'add_new_item' => __('新建幻灯片'),
- 'edit_item' => __('编辑'),
- 'new_item' => __('New slider Item'),
- 'view_item' => __('浏览全部幻灯片'),
- 'search_items' => __('查找'),
- 'not_found' => __('未找到'),
- 'not_found_in_trash' => __('垃圾箱中没有任何项目'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'menu_icon' => get_stylesheet_directory_uri() . '/images/theme_icon_slider.png',
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'can_export' => true,
- 'supports' => array('title','editor','thumbnail','custom-fields')
- );
- register_post_type( 'slider' , $args );
- }
调用
- <?php query_posts('showposts=4&post_type=slider');while(have_posts()):the_post();?>
- <li><a href="<?php the_permalink();?>" target="_blank"><?php if ( has_post_thumbnail() ) {the_post_thumbnail();} else {}?></a></li>
- <?php endwhile;wp_reset_query();?>
发布于记忆碎片-网络技术分享 https://huilang.me
文章地址:https://huilang.me/isay/wordpress-zeng-jia-slide-ye-mian-lei-xing/