azad_rpi

mix-it-up-for-tanvir

May 20th, 2014
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.34 KB | None | 0 0
  1. <!--=== Content Part ===-->
  2. <div class="container">    
  3.     <div class="row-fluid">
  4.         <div id="id">
  5.         <?php
  6.             $q = new WP_Query(
  7.                 array('posts_per_page' => '-1', 'post_type' => 'portfolio')
  8.                 );     
  9.                
  10.  
  11.         //Portfolio taxanomy query
  12.             $args = array(
  13.                 'post_type' => 'portfolio',
  14.                 'paged' => $paged,
  15.                 'posts_per_page' => '10',
  16.             );
  17.  
  18.             $portfolio = new WP_Query($args);
  19.             if(is_array($portfolio->posts) && !empty($portfolio->posts)) {
  20.                 foreach($portfolio->posts as $gallery_post) {
  21.                     $post_taxs = wp_get_post_terms($gallery_post->ID, 'portfolio_category', array("fields" => "all"));
  22.                     if(is_array($post_taxs) && !empty($post_taxs)) {
  23.                         foreach($post_taxs as $post_tax) {
  24.                             $portfolio_taxs[$post_tax->slug] = $post_tax->name;
  25.                         }
  26.                     }
  27.                 }
  28.             }
  29.         ?>
  30.     <?php if(is_array($portfolio_taxs) && !empty($portfolio_taxs) && get_post_meta($post->ID, 'pyre_portfolio_filters', true) != 'no') ?>
  31.  
  32.         <div class="sort" id="sort">
  33.             <ul class="unstyled inline">
  34.              <li><a href="#" class="all selected">Alle</a></li>        
  35.                 <?php foreach($portfolio_taxs as $portfolio_tax_slug => $portfolio_tax_name): ?>
  36.                 <li><a href="#" class="<?php echo $portfolio_tax_slug; ?>"><?php echo $portfolio_tax_name; ?></a></li>
  37.                 <?php endforeach; ?>
  38.             </ul>
  39.         </div>
  40.         <ul class="portfolio recent-work clearfix">
  41.             <?php
  42.                 while($q->have_posts()) : $q->the_post();
  43.                 $idd = get_the_ID();
  44.                 $portfolio_subtitle = get_post_meta($idd, 'portfolio_subtitle', true);
  45.                 $filterr = get_post_meta($idd, 'filterr', true);
  46.                 $small_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'project_small_image' );
  47.                 $full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'project_large_image' );
  48.                 //$small_image_url = the_post_thumbnail('project_smal_image', array('class' => 'post-thumb'));
  49.                
  50.                 //Get Texanmy class
  51.                
  52.                 $item_classes = '';
  53.                 $item_cats = get_the_terms($post->ID, 'portfolio_category');
  54.                 if($item_cats):
  55.                 foreach($item_cats as $item_cat) {
  56.                     $item_classes .= $item_cat->slug . '';
  57.                 }
  58.                 endif;
  59.             ?>
  60.                 <li data-id="id-100" class="<?php echo $item_classes; ?>">
  61.                     <a href="#">
  62.                         <em class="overflow-hidden"><img src="img/b.jpg" alt="" /></em>
  63.                         <span>
  64.                             <strong><?php the_title(); ?></strong>
  65.                             <i>Anim pariatur cliche reprehenderit</i>
  66.                         </span>
  67.                     </a>
  68.                 </li>
  69.             <?php endwhile; ?>
  70.             <?php wp_reset_query(); ?>
  71.         </ul>  
  72.       </div>                
  73.     </div><!--/row-fluid-->        
  74. </div><!--/container-->  
  75.  
  76.  
  77.  
  78.  
  79. function.php
  80. ===============================
  81. function create_post_type() {
  82.     register_post_type( 'portfolio',
  83.         array(
  84.             'labels' => array(
  85.                 'name' => __( 'Portfolio' ),
  86.                 'singular_name' => __( 'Portfolio' ),
  87.                 'add_new' => __( 'Add New' ),
  88.                 'add_new_item' => __( 'Add New Portfolio' ),
  89.                 'edit_item' => __( 'Edit Portfolio' ),
  90.                 'new_item' => __( 'New Portfolio' ),
  91.                 'view_item' => __('portfolio'),
  92.                 'not_found' => __( 'Sorry, we couldnt find the Portfolio you are looking for.' )
  93.             ),
  94.         'public' => true,
  95.         'publicly_queryable' => true,
  96.         'exclude_from_search' => true,
  97.         'menu_position' => 14,
  98.         'has_archive' => false,
  99.         'hierarchical' => false,
  100.         'capability_type' => 'page',
  101.         'rewrite' => array( 'slug' => 'portfolio' ),
  102.         'supports' => array( 'title', 'editor', 'custom-fields','thumbnail')
  103.         )
  104.     );
  105. }
  106. add_action( 'init', 'create_post_type' );
  107.  
  108.  
  109.  
  110.  
  111. function custom_post_taxonomy() {
  112.     register_taxonomy(
  113.         'portfolio_category',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
  114.         'portfolio',                  //post type name
  115.         array(
  116.             'hierarchical'          => true,
  117.             'label'                         => 'Portfolio Category',  //Display name
  118.             'query_var'             => true,
  119.             'show_admin_column'             => true,
  120.             'rewrite'                       => array(
  121.                 'slug'                  => 'portfolio-category', // This controls the base slug that will display before each term
  122.                 'with_front'    => true // Don't display the category base before
  123.                 )
  124.             )
  125.     );
  126. }
  127. add_action( 'init', 'custom_post_taxonomy');
Advertisement
Add Comment
Please, Sign In to add comment