Advertisement
rajesh-rajan

The actual homepage

May 20th, 2014
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. <!-- #content -->
  2. <section id="content" role="main">
  3.  
  4. <header id="page-header">
  5. <h2 class="page-title">
  6. <?php _e('Lesson Categories','framework') ?>
  7. </h2>
  8. </header>
  9. <div id="homepage-categories" class="clearfix">
  10. <?php
  11. // Get homepage options
  12. $st_hp_category_exclude = 0;
  13. $st_hp_category_exclude = of_get_option('st_hp_cat_exclude');
  14.  
  15. $st_hp_subcategory_exclude = 0;
  16. $st_hp_subcategory_exclude = of_get_option('st_hp_subcat_exclude');
  17.  
  18. // Set category counter
  19. $st_cat_counter = 0;
  20.  
  21. // Base Category Query
  22. $st_hp_cat_args = array(
  23. 'orderby' => 'name',
  24. 'order' => 'ASC',
  25. 'hierarchical' => true,
  26. 'hide_empty' => 0,
  27. 'exclude' => $st_hp_category_exclude,
  28. 'pad_counts' => 1
  29. );
  30.  
  31.  
  32. $st_categories = get_categories($st_hp_cat_args);
  33. $st_categories = wp_list_filter($st_categories,array('parent'=>0));
  34. // If there are catgegories
  35. if ($st_categories) {
  36. foreach($st_categories as $st_category) {
  37. $st_cat_counter++;
  38.  
  39. if ((!is_int($st_cat_counter / 2)) && $st_cat_counter != 1) {
  40. echo '</div><div class="row">';} elseif ($st_cat_counter == 1)
  41. { echo '<div class="row">';}
  42.  
  43. echo '<div class="column col-half '. $st_cat_counter.'">';
  44. echo '<h3> <a href="' . get_category_link( $st_category->term_id ) . '" title="' . sprintf( __( 'View all posts in %s', 'framework' ), $st_category->name ) . '" ' . '>' . $st_category->name.'</a>';
  45. if (of_get_option('st_hp_cat_counts') == '1') {
  46. echo '<span class="cat-count">(' . $st_category->count.')</span>';
  47. }
  48. echo '</h3>';
  49.  
  50. // Sub category
  51. $st_sub_category = get_category($st_category);
  52. $st_subcat_args = array(
  53. 'orderby' => 'name',
  54. 'order' => 'ASC',
  55. 'exclude' => $st_hp_subcategory_exclude,
  56. 'child_of' => $st_sub_category->cat_ID,
  57. 'pad_counts' => 1
  58. );
  59. $st_sub_categories = get_categories($st_subcat_args);
  60. $st_sub_categories = wp_list_filter($st_sub_categories,array('parent'=>$st_sub_category->cat_ID));
  61.  
  62. // If there are sub categories show them
  63. if ($st_sub_categories && (of_get_option('st_hp_subcat') == 1)) {
  64. foreach($st_sub_categories as $st_sub_category) { ?>
  65. <ul class="sub-categories">
  66. <li>
  67. <h4><?php echo '<a href="' . get_category_link( $st_sub_category->term_id ) . '" title="' . sprintf( __( 'View all posts in %s', 'framework' ), $st_sub_category->name ) . '" ' . '>' . $st_sub_category->name.'</a>';
  68. if (of_get_option('st_hp_subcat_counts') == '1') {
  69. echo '<span class="cat-count">(' . $st_sub_category->count.')</span>';
  70. } ?></h4>
  71. </li>
  72. </ul>
  73. <?php }
  74. }
  75.  
  76. //List Posts
  77. $st_cat_post_num = of_get_option('st_hp_cat_postnum');
  78. $st_posts_order = of_get_option('st_hp_cat_posts_order');
  79.  
  80. global $post;
  81.  
  82. // If show posts is 0 do nothing
  83. if ($st_cat_post_num != 0) {
  84.  
  85. // Listed by popular?
  86. if ($st_posts_order == 'meta_value_num') {
  87. $st_cat_post_args = array(
  88. 'numberposts' => $st_cat_post_num,
  89. 'orderby' => $st_posts_order,
  90. 'meta_key' => '_st_post_views_count',
  91. 'category__in' => $st_category->term_id
  92. );
  93. } else {
  94. $st_cat_post_args = array(
  95. 'numberposts' => $st_cat_post_num,
  96. 'orderby' => $st_posts_order,
  97. 'category__in' => $st_category->term_id
  98. );
  99. }
  100.  
  101. $st_cat_posts = get_posts($st_cat_post_args);
  102. echo '<ul class="category-posts">';
  103. foreach($st_cat_posts as $post) : setup_postdata($post);
  104. ?>
  105. <?php
  106. // Set post format class
  107. if ( has_post_format( 'video' )) {
  108. $st_postformat_class = 'video';
  109. } else {
  110. $st_postformat_class = 'standard';
  111. }
  112. ?>
  113. <li class="format-<?php echo $st_postformat_class; ?>"><a href="<?php the_permalink(); ?>">
  114. <?php the_title(); ?>
  115. </a></li>
  116.  
  117. <?php
  118. endforeach;
  119.  
  120. echo '</ul>';
  121. }
  122.  
  123. echo '</div>';
  124. }
  125. }
  126. ?>
  127. </div>
  128. </div>
  129.  
  130. </section>
  131. <!-- #content -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement