wordpress 增加Slide页面类型

2014.03.23 2346 人浏览 留言
  1. //该函数用于增加Slide页面类型。  
  2. add_action('init', 'slider_register');  
  3. function slider_register() {  
  4.   $labels = array(  
  5.     'name'          => _x('幻灯片', 'post type general name'),  
  6.     'singular_name'     => _x('幻灯片列表', 'post type singular name'),  
  7.     'add_new'       => _x('新建', 'slider item'),  
  8.     'add_new_item'      => __('新建幻灯片'),  
  9.     'edit_item'       => __('编辑'),  
  10.     'new_item'        => __('New slider Item'),  
  11.     'view_item'       => __('浏览全部幻灯片'),  
  12.     'search_items'      => __('查找'),  
  13.     'not_found'       => __('未找到'),  
  14.     'not_found_in_trash'  => __('垃圾箱中没有任何项目'),  
  15.     'parent_item_colon'   => ''  
  16.   );  
  17.   $args = array(  
  18.     'labels'        => $labels,  
  19.     'public'        => true,  
  20.     'publicly_queryable'  => true,  
  21.     'show_ui'       => true,  
  22.     'query_var'       => true,  
  23.     'menu_icon'       => get_stylesheet_directory_uri() . '/images/theme_icon_slider.png',  
  24.     'rewrite'       => true,  
  25.     'capability_type'   => 'post',  
  26.     'hierarchical'      => false,  
  27.     'menu_position'     => null,  
  28.     'can_export'      => true,  
  29.     'supports'        => array('title','editor','thumbnail','custom-fields')  
  30.     );   
  31.    
  32.   register_post_type( 'slider' , $args );  
  33. }  

调用

  1. <?php query_posts('showposts=4&post_type=slider');while(have_posts()):the_post();?>  
  2.   <li><a href="<?php the_permalink();?>" target="_blank"><?php if ( has_post_thumbnail() ) {the_post_thumbnail();} else {}?></a></li>  
  3. <?php endwhile;wp_reset_query();?>  

文章地址:https://huilang.me/isay/wordpress-zeng-jia-slide-ye-mian-lei-xing/

回复本文

您的电子邮箱地址不会被公开。 必填项已用 * 标注

icon_wink.gif icon_neutral.gif icon_mad.gif icon_twisted.gif icon_smile.gif icon_eek.gif icon_sad.gif icon_rolleyes.gif icon_razz.gif icon_redface.gif icon_surprised.gif icon_mrgreen.gif icon_lol.gif icon_idea.gif icon_biggrin.gif icon_evil.gif icon_cry.gif icon_cool.gif icon_arrow.gif icon_confused.gif icon_question.gif icon_exclaim.gif