RUSSEL86

mixitup by shortcode

Aug 2nd, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 portfolio_shortcode($atts){
  61. ob_start(); ?>
  62.  
  63. <div class="filter_area_wraper fix">
  64.     <div class="iso-nav fix">
  65.         <ul>
  66.             <li class="active" data-filter="*">כל הפריטים</li>
  67.              <?php $terms = get_terms( array(
  68.                 'taxonomy' => 'portfolio_category',
  69.                 'hide_empty' => true,
  70.                 ) );
  71.                 if ( !empty( $terms ) && !is_wp_error( $terms ) ){
  72.                 foreach ( $terms as $term ) { ?>
  73.                 <li data-filter=".cat<?php echo $term->term_id; ?>"><?php echo $term->name; ?></li>
  74.  
  75.                 <?php }
  76.                 } ?>
  77.            
  78.            
  79.         </ul>
  80.     </div>
  81.        
  82.          <?php $docu = new WP_Query(
  83.         array('posts_per_page' => -1, 'post_type' => 'portfolio', )
  84.         );    
  85.        
  86.     ?>
  87.        
  88.                            
  89.     <div class="main-iso fix">
  90.         <?php
  91.        
  92.         while( $docu->have_posts()) : $docu->the_post();
  93.         $item_classes = '';
  94.         $item_cats = get_the_terms($post->ID, 'portfolio_category');
  95.         if($item_cats):
  96.         foreach($item_cats as $item_cat) {
  97.                 $item_classes .= 'cat'.$item_cat->term_id . ' ';
  98.         }
  99.         endif;
  100.        
  101.         ?>    
  102.            
  103.         <div class="item <?php echo $item_classes; ?> col-md-3">
  104.             <div class="documentitem_wrapper fix">
  105.                 <div class="document_title fix">
  106.                     <h2><?php the_title();?></h2>
  107.                 </div>
  108.                 <div class="document_thumb fix">
  109.                    
  110.                     <?php if ( has_post_thumbnail() ): ?>
  111.                         <?php the_post_thumbnail(); ?>
  112.                     <?php else : ?>
  113.                         <img src="<?php echo get_template_directory_uri(); ?>/img/file_img.jpg" alt="" />
  114.                     <?php endif; ?>
  115.                 </div>
  116.                 <div class="document_linkarea fix">
  117.                     <div class="link_downld fix">
  118.                         <a href="<?php the_field('pdf_file');?>" class=
  119.                         "down_kor" download>הורד</a> |
  120.                     </div>
  121.                     <div class="link_preview fix">
  122.                        
  123.                         <button type="submit" onclick="window.open('<?php the_field('pdf_file');?>')" class=
  124.                         "previw_kor">צפה</button>
  125.                     </div>
  126.                 </div>
  127.             </div>
  128.         </div>
  129.        
  130.         <?php endwhile; ?>
  131.            
  132.            
  133.     </div>
  134.     <?php wp_reset_postdata(); ?>
  135.    
  136. </div>
  137.        
  138.        
  139.     <?php
  140.    
  141.     return ob_get_clean();
  142. }
  143. add_shortcode('portfolio', 'portfolio_shortcode');
Add Comment
Please, Sign In to add comment