azad_rpi

Mixitup-by-shoertcode

Jun 24th, 2014
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.40 KB | None | 0 0
  1. # Register Custom Post
  2. function rrf_post_type() {
  3.     register_post_type( 'portfolio',
  4.         array(
  5.             'labels' => array(
  6.                 'name' => __( 'Portfolio' ),
  7.                 'singular_name' => __( 'Portfolio' ),
  8.                 'add_new' => __( 'Add New' ),
  9.                 'add_new_item' => __( 'Add New Portfolio' ),
  10.                 'edit_item' => __( 'Edit Portfolio' ),
  11.                 'new_item' => __( 'New Portfolio' ),
  12.                 'view_item' => __('portfolio'),
  13.                 'not_found' => __( 'Sorry, we couldnt find the Portfolio you are looking for.' )
  14.             ),
  15.         'public' => true,
  16.         'publicly_queryable' => true,
  17.         'exclude_from_search' => true,
  18.         'has_archive' => false,
  19.         'hierarchical' => false,
  20.         'capability_type' => 'page',
  21.         'rewrite' => array( 'slug' => 'portfolio' ),
  22.         'supports' => array( 'title', 'editor', 'custom-fields','thumbnail')
  23.         )
  24.     );
  25. }
  26. add_action( 'init', 'rrf_post_type' );
  27.  
  28. # Register Custom Taxonomy For Portfolio
  29.  
  30. function rrf_post_taxonomy() {
  31.     register_taxonomy(
  32.         'portfolio_category',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
  33.         'portfolio',                  //post type name
  34.         array(
  35.             'hierarchical'          => true,
  36.             'label'                         => 'Portfolio Category',  //Display name
  37.             'query_var'             => true,
  38.             'show_admin_column'             => true,
  39.             'rewrite'                       => array(
  40.                 'slug'                  => 'portfolio-category', // This controls the base slug that will display before each term
  41.                 'with_front'    => true // Don't display the category base before
  42.                 )
  43.             )
  44.     );
  45. }
  46. add_action( 'init', 'rrf_post_taxonomy');
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. ======================================================
  54.  
  55. */Shortcode*/
  56.  
  57.  
  58. # Dynamic Portfolio With Shortcode
  59.  
  60. function rrf_portfolio_shortcode($atts){
  61.     extract( shortcode_atts( array(
  62.         'category' => ''
  63.     ), $atts, '' ) );
  64.    
  65.     $q = new WP_Query(
  66.         array('posts_per_page' => '-1', 'post_type' => 'portfolio')
  67.         );     
  68.        
  69.  
  70. //Portfolio taxanomy query
  71.     $args = array(
  72.         'post_type' => 'portfolio',
  73.         'paged' => $paged,
  74.         'posts_per_page' => $data['portfolio_items'],
  75.     );
  76.  
  77.     $portfolio = new WP_Query($args);
  78.     if(is_array($portfolio->posts) && !empty($portfolio->posts)) {
  79.         foreach($portfolio->posts as $gallery_post) {
  80.             $post_taxs = wp_get_post_terms($gallery_post->ID, 'portfolio_category', array("fields" => "all"));
  81.             if(is_array($post_taxs) && !empty($post_taxs)) {
  82.                 foreach($post_taxs as $post_tax) {
  83.                     $portfolio_taxs[$post_tax->slug] = $post_tax->name;
  84.                 }
  85.             }
  86.         }
  87.     }
  88.     if(is_array($portfolio_taxs) && !empty($portfolio_taxs) && get_post_meta($post->ID, 'pyre_portfolio_filters', true) != 'no'):
  89. ?>     
  90.  
  91.         <!--Category Filter-->
  92.         <div class="category-filter">
  93.             <ul>
  94.                 <?php foreach($portfolio_taxs as $portfolio_tax_slug => $portfolio_tax_name): ?>
  95.                 <li class="filter" data-category="<?php echo $portfolio_tax_slug; ?>"><?php echo $portfolio_tax_name; ?></li>
  96.                 <?php endforeach; ?>
  97.             </ul>
  98.         </div>
  99.         <!--End-->
  100.  
  101.         <?php endif; ?>
  102.  
  103. <?php
  104.  
  105.     $list = '<div class="portfolio-thumbnail"><div class="megafolio-container noborder">';
  106.     while($q->have_posts()) : $q->the_post();
  107.         $idd = get_the_ID();
  108.         //$portfolio_subtitle = get_post_meta($idd, 'portfolio_subtitle', true);
  109.         //$filterr = get_post_meta($idd, 'filterr', true);
  110.         $small_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio_small_image' );
  111.         //$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'portfolio_large_image' );
  112.         //$small_image_url = the_post_thumbnail('project_smal_image', array('class' => 'post-thumb'));
  113.        
  114.         //Get Texanmy class
  115.        
  116.         $item_classes = '';
  117.         $item_cats = get_the_terms($post->ID, 'portfolio_category');
  118.         if($item_cats):
  119.         foreach($item_cats as $item_cat) {
  120.             $item_classes .= $item_cat->slug . ' ';
  121.         }
  122.         endif;
  123.            
  124.         $single_link =
  125.         $list .= ' 
  126.        
  127.             <!--Thumbnail 1 Start-->
  128.             <div class="mega-entry '.$item_classes.'" id="" data-src="'.$small_image_url[0].'">
  129.                
  130.                 <!--Hover Effect Start-->
  131.                 <a class="" href="'.get_permalink().'">
  132.                     <div class="mega-hover alone notitle">
  133.                    
  134.                         <!-- Link Button -->
  135.                         <div class="mega-hoverview"></div>
  136.                          
  137.                     </div>
  138.                 </a>
  139.                 <!--Hover Effect End-->
  140.                
  141.             </div>
  142.            
  143.         ';        
  144.     endwhile;
  145.     $list.= '</div></div>';
  146.     wp_reset_query();
  147.     return $list;
  148. }
  149. add_shortcode('portfolio', 'rrf_portfolio_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment