RtThemesSupport

rttheme 13 rt_custom_posts.php

Jun 27th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.34 KB | None | 0 0
  1. <?php
  2. /*
  3. RT-Theme Custom Post Types Function
  4. */
  5.    
  6. function rt_theme_custom_posts(){
  7.  
  8.     //Portfolio
  9.     $labels = array(
  10.       'name' => _x('Portfolio', 'portfolio'),
  11.       'singular_name' => _x('portfolio', 'portfolio'),
  12.       'add_new' => _x('Add New', 'portfolio item'),
  13.       'add_new_item' => __('Add New portfolio item'),
  14.       'edit_item' => __('Edit Portfolio Item'),
  15.       'new_item' => __('New Portfolio Item'),
  16.       'view_item' => __('View Portfolio Item'),
  17.       'search_items' => __('Search Portfolio Item'),
  18.       'not_found' =>  __('No portfolio item found'),
  19.       'not_found_in_trash' => __('No portfolio item found in Trash'),
  20.       'parent_item_colon' => ''
  21.     );
  22.     $args = array(
  23.       'labels' => $labels,
  24.       'public' => true,
  25.       'publicly_queryable' => true,
  26.       'show_ui' => true,
  27.       'query_var' => true,
  28.       'capability_type' => 'post',
  29.       'menu_position' => null,
  30.       'rewrite' => array('slug'=>'portfolio','with_front'=>false),
  31.       'supports' => array('title','editor','author','thumbnail','comments')
  32.     );
  33.     register_post_type('portfolio',$args);
  34.    
  35.     // Portfolio Categories
  36.     $labels = array(
  37.       'name' => _x( 'Portfolio Categories', 'taxonomy general name' ),
  38.       'singular_name' => _x( 'Portfolio Category', 'taxonomy singular name' ),
  39.       'search_items' =>  __( 'Search Portfolio Category' ),
  40.       'all_items' => __( 'All Portfolio Categories' ),
  41.       'parent_item' => __( 'Parent Portfolio Category' ),
  42.       'parent_item_colon' => __( 'Parent Portfolio Category:' ),
  43.       'edit_item' => __( 'Edit Portfolio Category' ),
  44.       'update_item' => __( 'Update Portfolio Category' ),
  45.       'add_new_item' => __( 'Add New Portfolio Category' ),
  46.       'new_item_name' => __( 'New Genre Portfolio Category' ),
  47.     );  
  48.    
  49.     register_taxonomy('portfolio_categories',array('portfolio'), array(
  50.       'hierarchical' => true,
  51.       'labels' => $labels,
  52.       'show_ui' => true,
  53.       'query_var' => true,
  54.       '_builtin' => false,
  55.       'paged'=>true,
  56.       'rewrite' => array('slug'=>'portfolios','with_front'=>false),
  57.     ));
  58.    
  59.    
  60.     //Products
  61.     $labels = array(
  62.       'name' => _x('Products', 'product'),
  63.       'singular_name' => _x('product', 'product'),
  64.       'add_new' => _x('Add New', 'product'),
  65.       'add_new_item' => __('Add New Product'),
  66.       'edit_item' => __('Edit Product'),
  67.       'new_item' => __('New Product'),
  68.       'view_item' => __('View Product'),
  69.       'search_items' => __('Search Product'),
  70.       'not_found' =>  __('No product found'),
  71.       'not_found_in_trash' => __('No product found in Trash'),
  72.       'parent_item_colon' => ''
  73.     );
  74.     $args = array(
  75.       'labels' => $labels,
  76.       'public' => true,
  77.       'publicly_queryable' => true,
  78.       'show_ui' => true,
  79.       'query_var' => true,
  80.       'capability_type' => 'post',
  81.       'menu_position' => null,
  82.       'rewrite' => array('slug'=>'product','with_front'=>false),
  83.       'supports' => array('title','editor','author','thumbnail')
  84.     );
  85.     register_post_type('products',$args);
  86.    
  87.     // Product Categories
  88.     $labels = array(
  89.       'name' => _x( 'Product Categories', 'taxonomy general name' ),
  90.       'singular_name' => _x( 'Product Category', 'taxonomy singular name' ),
  91.       'search_items' =>  __( 'Search Product Category' ),
  92.       'all_items' => __( 'All Product Categories' ),
  93.       'parent_item' => __( 'Parent Product Category' ),
  94.       'parent_item_colon' => __( 'Parent Product Category:' ),
  95.       'edit_item' => __( 'Edit Product Category' ),
  96.       'update_item' => __( 'Update Product Category' ),
  97.       'add_new_item' => __( 'Add New Product Category' ),
  98.       'new_item_name' => __( 'New Genre Product Category' ),
  99.     );  
  100.    
  101.     register_taxonomy('product_categories',array('products'), array(
  102.       'hierarchical' => true,
  103.       'labels' => $labels,
  104.       'show_ui' => true,
  105.       'query_var' => true,
  106.       '_builtin' => false,
  107.       'paged'=>true,
  108.       'rewrite' => array('slug'=>'products','with_front'=>false),
  109.     ));
  110.      
  111.  
  112.     //Home Page Slider
  113.     $labels = array(
  114.       'name' => _x('Home Page Slider', 'slider'),
  115.       'singular_name' => _x('slider', 'slider'),
  116.       'add_new' => _x('Add New', 'slider'),
  117.       'add_new_item' => __('Add New Slide'),
  118.       'edit_item' => __('Edit Slide'),
  119.       'new_item' => __('New Slide'),
  120.       'view_item' => __('View Slide'),
  121.       'search_items' => __('Search Slide'),
  122.       'not_found' =>  __('No slide found'),
  123.       'not_found_in_trash' => __('No slide found in Trash'),
  124.       'parent_item_colon' => ''
  125.     );
  126.     $args = array(
  127.       'labels' => $labels,
  128.       'public' => true,
  129.       'publicly_queryable' => true,
  130.       'show_ui' => true,
  131.       'query_var' => true,
  132.       'capability_type' => 'post',
  133.       'menu_position' => null,   
  134.       'exclude_from_search' => true,
  135.       'rewrite' => array('slug'=>'slide','with_front'=>false),
  136.       'supports' => array( 'title', 'thumbnail' )
  137.     );
  138.     register_post_type('slider',$args);
  139.    
  140.     //Home Page Contents
  141.     $labels = array(
  142.       'name' => _x('Home Page Contents', 'home_page'),
  143.       'singular_name' => _x('home_page', 'home_page'),
  144.       'add_new' => _x('Add New Box', 'home_page'),
  145.       'add_new_item' => __('Add New Box'),
  146.       'edit_item' => __('Edit Content'),
  147.       'new_item' => __('New Content'),
  148.       'view_item' => __('View Content'),
  149.       'search_items' => __('Search Content'),
  150.       'not_found' =>  __('No result found'),
  151.       'not_found_in_trash' => __('No result found in Trash'),
  152.       'parent_item_colon' => ''
  153.     );
  154.     $args = array(
  155.       'labels' => $labels,
  156.       'public' => true,
  157.       'publicly_queryable' => true,
  158.       'show_ui' => true,
  159.       'query_var' => true,
  160.       'capability_type' => 'post',
  161.       'menu_position' => null,   
  162.       'exclude_from_search' => true,
  163.       'supports' => array( 'title','editor','author','thumbnail')
  164.     );
  165.     register_post_type('home_page',$args);
  166.    
  167. }
  168.  
  169. #
  170. # Paging fix for custom post archives
  171. #
  172.  
  173. function rt_custom_post_limits( $value )
  174. {
  175.  
  176.     if(is_tax()){
  177.  
  178.         $post_per_page = 0;
  179.  
  180.         if(get_query_var('product_categories') || get_query_var('taxonomy')=="product_categories"){
  181.             $post_per_page=get_option('rttheme_product_list_pager');
  182.         }elseif(get_query_var('portfolio_categories') || get_query_var('taxonomy')=="portfolio_categories"){
  183.             $post_per_page=get_option('rttheme_portf_pager');
  184.         }
  185.        
  186.         if($post_per_page>0){  
  187.             return $post_per_page;
  188.         }else{
  189.             return $value;
  190.         }
  191.    
  192.     }elseif(get_query_var('s')!=""){
  193.         $post_per_page=20;
  194.         return $post_per_page;
  195.     }else{
  196.         return $value;
  197.     }
  198. }
  199.  
  200. function rt_modify_posts_per_page() {
  201.     add_filter( 'option_posts_per_page', 'rt_custom_post_limits');
  202. }
  203.  
  204. add_action('init','rt_modify_posts_per_page');
  205.  
  206. ?>
Advertisement
Add Comment
Please, Sign In to add comment