Advertisement
asadsuman

Mixitup

Apr 28th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.22 KB | None | 0 0
  1. <!-------------Mixit up Dynamic---------->
  2.  
  3. -----------------------------------------------WordPress Template Code:---------------------------------------
  4. <div class="col-md-12">
  5. <!-- Filters -->
  6. <?php if(!is_tax()) {
  7. $terms = get_terms("days");
  8. $count = count($terms);
  9. if ( $count > 0 ){ ?>
  10. <ul id="filterOptions" class="tonight-filter-list clearfix">
  11. <li class="filter" data-filter="all"><?php _e('All', 'listify'); ?></li>
  12. <?php foreach ( $terms as $term ) {
  13. echo '<li class="filter" data-filter="'.$term->slug.'">'. $term->name .'</li>';
  14. } ?>
  15. </ul><?php } } ?>
  16. </div>
  17.  
  18. <div class="col-md-12">
  19. <ul id="tonight" class="tonight-images">
  20. <?php
  21. $tonight_post = new WP_Query(array(
  22. 'post_type' => 'tonight'
  23. ));?>
  24. <li <?php post_class('mix');?>><?php the_post_thumbnail('tonight', array('class' => 'tonightmix'));?></li>
  25. <?php endwhile;?>
  26. </ul>
  27. </div>
  28.  
  29. ------------------------------------------------------------------functions.php Code------------------------------------
  30. /* ----------------------------------------------------- */
  31. /* Register Custom Post */
  32. /* ----------------------------------------------------- */
  33. add_action( 'init', 'register_listify_portfolio' );
  34.  
  35. function register_listify_portfolio() {
  36. $labels = array(
  37. 'name' => __( 'Tonight','listify'),
  38. 'singular_name' => __( 'Tonight','listify'),
  39. 'add_new' => __( 'Add New','listify' ),
  40. 'add_new_item' => __( 'Add New Day','listify' ),
  41. 'edit_item' => __( 'Edit Day','listify'),
  42. 'new_item' => __( 'New Day','listify'),
  43. 'view_item' => __( 'View Day','listify'),
  44. 'search_items' => __( 'Search Tonight','listify'),
  45. 'not_found' => __( 'No tonight found','listify'),
  46. 'not_found_in_trash' => __( 'No day found in Trash','listify'),
  47. 'parent_item_colon' => __( 'Parent day:','listify'),
  48. 'menu_name' => __( 'Tonight','listify'),
  49. );
  50.  
  51. $args = array(
  52. 'labels' => $labels,
  53. 'hierarchical' => false,
  54. 'description' => 'Display your day by filters',
  55. 'supports' => array( 'title', 'custom-fields', 'thumbnail' ),
  56.  
  57. 'public' => true,
  58. 'show_ui' => true,
  59. 'show_in_menu' => true,
  60. 'show_in_nav_menus' => false,
  61. 'publicly_queryable' => true,
  62. 'exclude_from_search' => false,
  63. 'has_archive' => true,
  64. 'query_var' => true,
  65. 'can_export' => true,
  66. 'rewrite' => true,
  67. 'capability_type' => 'post'
  68. );
  69.  
  70. register_post_type( 'tonight', $args );
  71. }
  72. /* ----------------------------------------------------- */
  73. /* Filter Taxonomy */
  74. /* ----------------------------------------------------- */
  75.  
  76. add_action( 'init', 'register_taxonomy_filters_listify' );
  77.  
  78. function register_taxonomy_filters_listify() {
  79. $labels = array(
  80. 'name' => __( 'Day', 'listify' ),
  81. 'singular_name' => __( 'Day', 'listify' ),
  82. 'search_items' => __( 'Search Day', 'listify' ),
  83. 'popular_items' => __( 'Popular Day', 'listify' ),
  84. 'all_items' => __( 'All Days', 'listify' ),
  85. 'parent_item' => __( 'Parent Day', 'listify' ),
  86. 'parent_item_colon' => __( 'Parent Day:', 'listify' ),
  87. 'edit_item' => __( 'Edit Day', 'listify' ),
  88. 'update_item' => __( 'Update Day', 'listify' ),
  89. 'add_new_item' => __( 'Add New Day', 'listify' ),
  90. 'new_item_name' => __( 'New Day', 'listify' ),
  91. 'separate_items_with_commas' => __( 'Separate Day with commas', 'listify' ),
  92. 'add_or_remove_items' => __( 'Add or remove Day', 'listify' ),
  93. 'choose_from_most_used' => __( 'Choose from the most used Day', 'listify' ),
  94. 'menu_name' => __( 'Days', 'listify' ),
  95. );
  96.  
  97. $args = array(
  98. 'labels' => $labels,
  99. 'public' => true,
  100. 'show_in_nav_menus' => false,
  101. 'show_ui' => true,
  102. 'show_tagcloud' => false,
  103. 'hierarchical' => true,
  104.  
  105. 'rewrite' => true,
  106. 'query_var' => true
  107. );
  108.  
  109. register_taxonomy( 'days', array('tonight'), $args );
  110. }
  111.  
  112. /*
  113. * Adds terms from a custom taxonomy to post_class
  114. */
  115. add_filter( 'post_class', 'theme_t_wp_taxonomy_post_class', 10, 3 );
  116. function theme_t_wp_taxonomy_post_class( $classes, $class, $ID ) {
  117. $taxonomy = 'days';
  118. $tt = get_the_terms( (int) $ID, $taxonomy );
  119. if( !empty( $tt ) ) {
  120. foreach( (array) $tt as $order => $term ) {
  121. if( !in_array( $term->slug, $classes ) ) {
  122. $classes[] = $term->slug;
  123. }
  124. }
  125. }
  126. return $classes;
  127. }
  128.  
  129. --------------------------------------------------------jQuery code--------------------------------------
  130. //mixitup
  131. jQuery(function(){
  132. // Instantiate MixItUp:
  133. jQuery('#tonight').mixItUp();
  134. });
  135.  
  136.  
  137. ------------------------------------------------CSS CODE----------------
  138. #tonight .mix{
  139. display: none;
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement