Advertisement
arnabkumar

my_mixitup_code

Sep 9th, 2014
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.30 KB | None | 0 0
  1. <?php
  2.  
  3. // html, css and jquery part
  4.  
  5. /* html img size 300 x 200*/
  6.  
  7. call js - <!--call jquery.mixitup.js-->
  8.        
  9.         <script src="js/jquery.mixitup.js"></script>
  10. <div class="mixi_tup_all">
  11.                  <div class="mixi_tup_filter">
  12.                             <ul class="mixi_tup_menu">
  13.                                 <li class="filter" data-filter="all">All</li>
  14.                                 <li class="filter" data-filter=".website">Web design</li>
  15.                                 <li class="filter" data-filter=".web">Web</li>
  16.                                 <li class="filter" data-filter=".video">video</li>
  17.                                 <li class="filter" data-filter=".illustration">illustration</li>
  18.                                 <li class="filter" data-filter=".audio">audio</li>
  19.                             </ul>
  20.                         </div>
  21.                 <div id="mix_container">
  22.                     <div class="mix website web single_project">
  23.                     <div class="color_overlay"></div>
  24.                     <div class="project_hover">
  25.                       <h2>this is title</h2>
  26.                       <a href=""><i class="fa fa-link"></i></a>
  27.                       <a href=""><i class="fa fa-search"></i></a>
  28.                     </div>
  29.                     <img src="images/single_project.jpg" alt="" />
  30.                     </div>
  31.                     <div class="mix web website illustration audio single_project">
  32.                     <div class="color_overlay"></div>
  33.                     <div class="project_hover">
  34.                       <h2>this is title</h2>
  35.                       <a href=""><i class="fa fa-link"></i></a>
  36.                       <a href=""><i class="fa fa-search"></i></a>
  37.                     </div>
  38.                     <img src="images/single_projet_two.jpg" alt="" />
  39.                     </div>
  40.                     <div class="mix video web website illustration audio single_project">
  41.                     <div class="color_overlay"></div>
  42.                     <div class="project_hover">
  43.                       <h2>this is title</h2>
  44.                       <a href=""><i class="fa fa-link"></i></a>
  45.                       <a href=""><i class="fa fa-search"></i></a>
  46.                     </div>
  47.                     <img src="images/single_project.jpg" alt="" />
  48.                     </div>
  49.                     <div class="mix illustration web website single_project">
  50.                     <div class="color_overlay"></div>
  51.                     <div class="project_hover">
  52.                       <h2>this is title</h2>
  53.                       <a href=""><i class="fa fa-link"></i></a>
  54.                       <a href=""><i class="fa fa-search"></i></a>
  55.                     </div>
  56.                     <img src="images/single_projet_two.jpg" alt="" />
  57.                     </div>
  58.                     <div class="mix audio website illustration single_project">
  59.                     <div class="color_overlay"></div>
  60.                     <div class="project_hover">
  61.                       <h2>this is title</h2>
  62.                       <a href=""><i class="fa fa-link"></i></a>
  63.                       <a href=""><i class="fa fa-search"></i></a>
  64.                     </div>
  65.                     <img src="images/single_project.jpg" alt="" />
  66.                     </div>
  67.                 </div>
  68.                  </div>
  69.  
  70.                  /*css*/
  71.  
  72. /*mixitup*/
  73. ul.mixi_tup_menu {text-align: center;}
  74. ul.mixi_tup_menu li{cursor: pointer;display: inline-block;padding: 10px;}
  75.  
  76.  
  77. .mixi_tup_all{clear: both;
  78. overflow: hidden;
  79. }
  80. #mix_container{margin-left: -10px;
  81. overflow: hidden;}
  82. .single_project{margin-left: 10px;float: left;width: 313px;position:relative;}
  83. .color_overlay{background:red;display: block;height: 100%;left: 0;
  84. position: absolute;top: 0;width: 100%;z-index: 9999;opacity:.4;display:none;}
  85. .project_hover{position:absolute;top:0;left:0;width:100%;height:100%;background:#6666cc;text-align: center;display:none;z-index:999;}
  86.  
  87. .single_project:hover .project_hover, .single_project:hover .color_overlay{display:block;}
  88. .project_hover a {background: none repeat scroll 0 0 #ffffff;padding: 8px;display:inline-block;}
  89. .project_hover a:hover{background:#9933cc;}
  90. .project_hover h2 {margin: 22px auto;font-size: 24px;}
  91.  
  92. .mix{display:none;}
  93.  
  94. .slider_area{position:relative;}
  95. .slider_area_preloader{}
  96. .slider_area_preloader_active{background: none repeat scroll 0 0 #808080;
  97. display: block;
  98. height: 100%;
  99. left: 50%;
  100. margin-left: -480px;
  101. position: absolute;
  102. top: 13%;
  103. width: 960px;
  104. z-index: 9;}
  105.  
  106.  
  107. /*jquery*/
  108. $(document).ready(function(){
  109.    
  110.     // Target your .container, .wrapper, .post, etc.    
  111.      $('#mix_container').mixItUp({
  112.     animation: {
  113.         effects: 'rotateX'
  114.     }
  115.   });  
  116.  
  117.    });
  118.  
  119.  
  120.  
  121.  
  122.  
  123. /*mixitup My code in wp twentytwelve theme  */
  124.  
  125.    /*in functions.php*/
  126. /*  Add Theme Support for Post Thumbnails*/
  127.  
  128.     add_theme_support( 'post-thumbnails' );
  129.  
  130.  
  131.     add_image_size( 'mixitup_mage', 320, 250, true );  
  132.  
  133.  
  134.      // Register Custom Post
  135.  
  136. function mixitup_post_type_f() {
  137.    
  138.     /* this is for create custom post */
  139.         register_post_type( 'mixitup_post',
  140.             array(
  141.                 'labels' => array(
  142.                         'name' => __( 'Mixitups' ),
  143.                         'singular_name' => __( 'Mixitup' ),
  144.                         'add_new' => __( 'Add New ' ),
  145.                         'add_new_item' => __( 'Add New Mixitup 320 x 250' ),
  146.                         'edit_item' => __( 'Edit Mixitup' ),
  147.                         'new_item' => __( 'New Mixitup' ),
  148.                         'view_item' => __( 'View Mixitup' ),
  149.                         'not_found' => __( 'Sorry, we couldn\'t find the Mixitup you are looking for.' )
  150.                 ),
  151.      
  152.            
  153.             'public' => true,
  154.             'menu_icon' => ('dashicons-sos'),
  155.             'publicly_queryable' => true,
  156.             'exclude_from_search' => true,
  157.             'menu_position' => 3,
  158.             'has_archive' => true,
  159.             'hierarchical' => true,
  160.             'capability_type' => 'post',
  161.             'rewrite' => array( 'slug' => 'mixitup' ),
  162.             'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail' )
  163.             )
  164.         );
  165.    
  166.        
  167.             }
  168.    
  169.    
  170.     add_action( 'init', 'mixitup_post_type_f' );
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178. // Register Custom Taxonomy
  179.  
  180.  
  181. function mixitup_taxonomy_f() {
  182.         register_taxonomy(
  183.                 'mixitup_taxonomy_cat',  /*The name of the taxonomy. Name should be in slug form    (must not contain capital letters or spaces).
  184.                 eta unic hobe post quary r somoy eta lagbe like
  185.                 'slider_cat' => 'slider photo'*/
  186.                 'mixitup_post',                  /*post type je name reg kora ache (poster itemer nam)*/
  187.                 array(
  188.                         'hierarchical'          => true,
  189.                         'label'                         => 'Mixitup Category',  /*Display name(eta) displete dakhabe */
  190.                         'query_var'             => true,
  191.                         'rewrite'                       => array(
  192.                                 'slug'                  => 'mixitup-category', // This controls the base slug that will display before each term
  193.                                 'with_front'    => false // Don't display the category base before
  194.                                 )
  195.                         )
  196.         );
  197. }
  198. add_action( 'init', 'mixitup_taxonomy_f');
  199.  
  200.  
  201.  
  202.  
  203. /*
  204. * Adds terms from a custom taxonomy to post_class
  205. */
  206. add_filter( 'post_class', 'mixitup_taxonomy_post_class', 10, 3 );
  207.  
  208. function mixitup_taxonomy_post_class( $classes, $class, $ID ) {
  209. $taxonomy = 'mixitup_taxonomy_cat';
  210. $terms = get_the_terms( (int) $ID, $taxonomy );
  211. if( !empty( $terms ) ) {
  212. foreach( (array) $terms as $order => $term ) {
  213. if( !in_array( $term->slug, $classes ) ) {
  214. $classes[] = $term->slug;
  215. }
  216. }
  217. }
  218. return $classes;
  219. }
  220.  
  221.  
  222.  
  223. // in index.php or custom template etc
  224.  
  225. <div class="mixi_tup_all">
  226.                  <div class="mixi_tup_filter">
  227.                     <!-- menu filter -->
  228.                     <?php if(!is_tax()) {
  229.                     $terms = get_terms("mixitup_taxonomy_cat");
  230.                     $count = count($terms);
  231.                     if ( $count > 0 ){ ?>
  232.                             <ul class="mixi_tup_menu">
  233.         <li class="filter" data-filter="all"><?php  _e('All'); ?></li>
  234.                            
  235.             <?php
  236. foreach ( $terms as $term ) {
  237. echo '<li class="filter" data-filter=".'.$term->slug.'">'. $term->name .'</li>';
  238. } ?>
  239.                             </ul>
  240.                             <?php } } ?>
  241.                         </div>
  242.          
  243.  
  244.                 <div id="mix_container">
  245.                         <?php
  246.                 global $post;
  247.                 $args = array( 'posts_per_page' => -1, 'post_type'=> 'mixitup_post',);
  248.                 $myposts = get_posts( $args );
  249.                 foreach( $myposts as $post ) : setup_postdata($post); ?>
  250.  
  251.  
  252.                 <!-- call taxonomi as post class -->
  253.  
  254.         <div <?php post_class('mix single_project'); ?>>
  255.                     <div class="color_overlay"></div>
  256.                     <div class="project_hover">
  257.                       <h2><?php the_title(); ?></h2>
  258.                       <a href=""><i class="fa fa-link"></i></a>
  259.                       <a href=""><i class="fa fa-search"></i></a>
  260.                     </div>
  261.                     <?php the_post_thumbnail('mixitup_mage'); ?>
  262.                     </div>
  263.                         <?php endforeach; ?>
  264.                    
  265.                    
  266.                 </div>
  267.  
  268.  
  269.  
  270. <!-- shortcode -->
  271.  
  272. /*[mixitup_shortcode]
  273. need to change - 'mixitup_post'
  274.  
  275. 'mixitup_taxonomy_cat'
  276. html markap
  277.  
  278. */
  279.  
  280.  
  281. function mixitup_shortcode_f($atts){
  282.             extract( shortcode_atts( array(
  283.                     'category' => ''
  284.             ), $atts, 'mixitup_shortcode' ) );
  285.            
  286.         $q = new WP_Query(
  287.             array('posts_per_page' => '-1', 'post_type' => 'mixitup_post')
  288.             );            
  289.            
  290.      
  291.     //Portfolio taxanomy query
  292.             $args = array(
  293.                     'post_type' => 'mixitup_post',
  294.                     'paged' => $paged,
  295.                     'posts_per_page' => $data['portfolio_items'],
  296.             );
  297.      
  298.             $portfolio = new WP_Query($args);
  299.             if(is_array($portfolio->posts) && !empty($portfolio->posts)) {
  300.                     foreach($portfolio->posts as $gallery_post) {
  301.                             $post_taxs = wp_get_post_terms($gallery_post->ID, 'mixitup_taxonomy_cat', array("fields" => "all"));
  302.                             if(is_array($post_taxs) && !empty($post_taxs)) {
  303.                                     foreach($post_taxs as $post_tax) {
  304.                                             $portfolio_taxs[$post_tax->slug] = $post_tax->name;
  305.                                     }
  306.                             }
  307.                     }
  308.             } //Here must be used category name (mixitup_taxonomy_cat).
  309.             if(is_array($portfolio_taxs) && !empty($portfolio_taxs) && get_post_meta($post->ID, 'pyre_portfolio_filters', true) != 'no'):
  310.     ?>
  311.                     <!-- Here is HTML nav menu and Query -->
  312.                     <div class="mixi_tup_all">
  313.                     <div class="mixi_tup_filter">
  314.                             <ul class="mixi_tup_menu">
  315.     <li class="filter" data-filter="all">All</li>
  316.    
  317.     <?php foreach($portfolio_taxs as $portfolio_tax_slug => $portfolio_tax_name): ?>
  318.  
  319.     <li class="filter" data-filter=".<?php echo $portfolio_tax_slug; ?>"><?php echo $portfolio_tax_name; ?></li>
  320.     <?php endforeach; ?>
  321.                             </ul>
  322.                     </div>
  323.      
  324.                     <?php endif; ?>
  325.      
  326.     <?php
  327.      
  328.             $list = '              
  329.                            <div id="mix_container">';
  330.             while($q->have_posts()) : $q->the_post();
  331.                     $idd = get_the_ID();
  332.                      $small_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'mixitup_img' );
  333.                    
  334.                     //Get Texanmy class
  335.                    
  336.                     $item_classes = '';
  337.                     $item_cats = get_the_terms($post->ID, 'mixitup_taxonomy_cat');
  338.                     if($item_cats):
  339.                     foreach($item_cats as $item_cat) {
  340.                             $item_classes .= $item_cat->slug . ' ';
  341.                     }
  342.                     endif;
  343.                            
  344.            
  345.                     $list .= '<div class="mix single_project '.$item_classes.'">
  346.                    <div class="color_overlay"></div>
  347.                    <div class="project_hover">
  348.                      <h2><?php the_title(); ?></h2>
  349.                      <a href=""><i class="fa fa-link"></i></a>
  350.                      <a href=""><i class="fa fa-search"></i></a>
  351.                    </div>
  352.                    <img src="'.$small_image_url[0].'" alt="">
  353.                    </div>
  354.                    ';        
  355.             endwhile;
  356.             $list.= '</div></div>';
  357.             wp_reset_query();
  358.             return $list;
  359.     }
  360.     add_shortcode('mixitup_shortcode', 'mixitup_shortcode_f');
  361.  
  362.  
  363. // use - [mixitup_shortcode]
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement