Advertisement
srice

Custom Functions

Oct 17th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.42 KB | None | 0 0
  1. <?php
  2. /* By taking advantage of hooks, filters, and the Custom Loop API, you can make Thesis
  3. * do ANYTHING you want. For more information, please see the following articles from
  4. * the Thesis User’s Guide or visit the members-only Thesis Support Forums:
  5. *
  6. * Hooks: http://diythemes.com/thesis/rtfm/customizing-with-hooks/
  7. * Filters: http://diythemes.com/thesis/rtfm/customizing-with-filters/
  8. * Custom Loop API: http://diythemes.com/thesis/rtfm/custom-loop-api/
  9. ---:[ place your custom code below this line ]:---*/
  10. // sticky footer
  11. function div_push() {
  12. ?>
  13. <div class="push"></div>
  14. <?php
  15. }
  16. function div_wrapper_start() {
  17. ?>
  18. <div class="wrapper">
  19. <?php
  20. }
  21. function div_wrapper_close() {
  22. ?>
  23. </div><!--end wrapper-->
  24. <?php
  25. }
  26. class my_loops extends thesis_custom_loop
  27. {
  28. function home()
  29. {?>
  30. <p id="fBread"><a href="http://www.magnetmediafilms.com/">Home</a> Our Work</p>
  31. <div id="diagBar"></div>
  32. <?php if(is_home() && !is_paged()) { ?>
  33. <div id="featureditems">
  34. <h1 id="feat_title">Featured Case Studies</h1>
  35. <?php
  36. global $post;
  37. $args = array( 'numberposts' => '3', 'category' => '59' );
  38. $myposts = get_posts( $args );
  39. foreach( $myposts as $post ) : setup_postdata($post); ?>
  40. <div class="featureditem">
  41. <a href="<?php the_permalink(); ?>"><div class="feattop">
  42. <h2><?php echo get_the_title(); ?></h2>
  43. <?php the_post_thumbnail('featured_thumb'); ?>
  44. </div></a>
  45. <div class="excerpt"><?php the_excerpt(); ?></div>
  46. <p class="more"><a href="<?php the_permalink(); ?>">+ full overview</a></p>
  47. </div>
  48. <?php endforeach; ?>
  49. <h1 id="explore_more">Explore More</h1>
  50. </div>
  51. <?php } ?>
  52. <div id='caseTumbs'>
  53. <? $tags = array(); $i = 0; ?>
  54. <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
  55. <? $args = array( 'posts_per_page' => '16', 'post_type' => 'post', 'cat' => '44, -59', 'paged'=> get_query_var('paged') ); $my_query = new WP_Query($args); ?>
  56. <? while($my_query->have_posts()): ?>
  57. <? $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
  58. <? $_tags = array();$c = '';
  59. $posttags = get_the_tags();
  60. if ($posttags)
  61. {
  62. foreach($posttags as $tag)
  63. {
  64. array_push( $_tags, $tag->name );
  65. $c .= $tag->slug . ' ';
  66. }
  67. }
  68. $thetags = array_unique( array_merge( $_tags, $tags ) );
  69. $tags = $thetags;
  70. $i++; ?>
  71. <? if ( $i % 4 == 0 ) : ?>
  72. <a href="<? the_permalink(); ?>" class="caseThumb four <? echo $c; ?>">
  73. <? else : ?>
  74. <a href="<? the_permalink(); ?>" class="caseThumb <? echo $c; ?>">
  75. <? endif; ?>
  76. <?php if ( has_post_thumbnail() ) { the_post_thumbnail('standard_thumb'); } ?>
  77. <br><?php echo get_the_title($ID); ?></a>
  78. <? endwhile; ?>
  79. </div>
  80. <? make_dropdown(); ?>
  81. <script>$(document).ready(function(){if ( $('.caseThumb').length < 16 ) { $('p.previous').hide(); } });</script>
  82. <?}
  83. function category()
  84. {?>
  85. <p id="fBread"><a href="http://www.magnetmediafilms.com/">Home</a> <a href="http://www.magnetmediafilms.com/casestudies">Our Work</a> <? wp_title("",true); ?></p>
  86. <div id="diagBar"></div>
  87. <div id='caseTumbs'>
  88. <? $i = 0; ?>
  89. <? if ( have_posts() ): while( have_posts() ) : ?>
  90. <? the_post(); $i++; ?>
  91. <? if ( $i % 4 == 0 ) : ?>
  92. <a href="<? the_permalink(); ?>" class="caseThumb four">
  93. <? else : ?>
  94. <a href="<? the_permalink(); ?>" class="caseThumb">
  95. <? endif; ?>
  96. <?php if ( has_post_thumbnail() ) { the_post_thumbnail('standard_thumb'); } ?>
  97. <br><?php echo get_the_title($ID); ?></a>
  98. <? endwhile; endif; ?>
  99. </div>
  100. <? make_dropdown(); ?>
  101. <?}
  102. function tag()
  103. {?>
  104. <p id="fBread"><a href="http://www.magnetmediafilms.com/">Home</a> <a href="http://www.magnetmediafilms.com/casestudies">Our Work</a> <? wp_title("",true); ?></p>
  105. <div id="diagBar"></div>
  106. <div id='caseTumbs'>
  107. <? $i = 0; ?>
  108. <? if ( have_posts() ): while( have_posts() ) : ?>
  109. <? the_post(); $i++; ?>
  110. <? if ( $i % 4 == 0 ) : ?>
  111. <a href="<? the_permalink(); ?>" class="caseThumb four">
  112. <? else : ?>
  113. <a href="<? the_permalink(); ?>" class="caseThumb">
  114. <? endif; ?>
  115. <?php if ( has_post_thumbnail() ) { the_post_thumbnail('standard_thumb'); } ?>
  116. <br><?php echo get_the_title($ID); ?></a>
  117. <? endwhile; endif; ?>
  118. </div>
  119. <? make_dropdown(); ?>
  120. <?}
  121. function single()
  122. {
  123. if ( have_posts() )
  124. {
  125. while( have_posts() )
  126. {
  127. the_post(); ?>
  128. <p id="fBread"><a href="http://www.magnetmediafilms.com/">Home</a> <a href="http://www.magnetmediafilms.com/casestudies">Our Work</a> <? wp_title("",true); ?></p>
  129. <div id="diagBar"></div>
  130. <div id="lCol">
  131. <div class="upper">
  132. <? $logo = get_post_meta( get_the_ID(), 'client_logo', true ); ?>
  133. <? if ( $logo ): ?>
  134. <img src="<? echo $logo; ?>" />
  135. <? endif; ?>
  136. <h6>CLIENT</h6>
  137. <?php the_tags('<ul><li>','</li><li>','</li></ul>'); ?>
  138. <!--<p><? #echo get_post_meta( get_the_ID(), 'client_name', true ); ?></p>-->
  139. <h6>SERVICES</h6>
  140. <ul>
  141. <? $cat = get_the_category();
  142. foreach( $cat as $_cat )
  143. {
  144. if ( $_cat->cat_name != "Case Studies" && $_cat->cat_name != "Featured")
  145. {
  146. echo "<li><a href='http://www.magnetmediafilms.com/casestudies/category/" . $_cat->slug ."'>" . $_cat->cat_name . "</a></li>";
  147. }
  148. } ?>
  149. </ul>
  150. <h6>LINKS</h6>
  151. <ul>
  152. <?
  153. $links = get_post_meta( get_the_ID(), 'study_links', true );
  154. $_l = explode(',', $links);
  155. foreach( $_l as $__l ) { echo "<li>" . $__l . "</li>"; };
  156. ?>
  157. </ul>
  158. </div>
  159. <div class="lower">
  160. <br><br><a href="http://www.magnetmediafilms.com/contact/">Contact us for a quote!</a>
  161. </div>
  162. </div>
  163. <div id="rCol">
  164. <h2 class="title"><? the_title(); ?></h2>
  165. <? the_content(); ?>
  166. </div>
  167. <? make_dropdown(); ?>
  168. <?}
  169. }?>
  170. <?php
  171. $cats = get_the_category();
  172. if ($cats)
  173. {
  174. $cat_ids = array();
  175. foreach($cats as $individual_cat) $cat_ids[] = $individual_cat->term_id;
  176. $args=array(
  177. 'category__and' => $cat_ids,
  178. 'post__not_in' => array(get_the_ID()),
  179. 'showposts'=> '4',
  180. 'caller_get_posts' => '1'
  181. );
  182. $my_query = new wp_query($args);
  183. if( $my_query->have_posts() ) {
  184. echo '<div id="related">';
  185. while ($my_query->have_posts())
  186. {
  187. $my_query->the_post(); ?>
  188. <a href="<? the_permalink(); ?>" class="caseThumb">
  189. <?php if ( has_post_thumbnail() ) { the_post_thumbnail('standard_thumb'); } ?>
  190. <br><?php echo get_the_title($ID); ?></a>
  191. <? }
  192. echo '</div>';
  193. }
  194. }
  195. }
  196. }
  197. $blah = new my_loops;
  198. function make_dropdown()
  199. { ?>
  200. <div id="tagSelector">
  201. <select onchange='document.location.href=this.options[this.selectedIndex].value;'>
  202. <option value="">Select Service</option>
  203. <option value="http://www.magnetmediafilms.com/casestudies/">View All</option>
  204. <option value="http://www.magnetmediafilms.com/casestudies/category/video-production">Video Production</option>
  205. <option value="http://www.magnetmediafilms.com/casestudies/category/customer-stories">&mdash; Customer stories</option>
  206. <option value="http://www.magnetmediafilms.com/casestudies/category/product-videos">&mdash; Product Videos</option>
  207. <option value="http://www.magnetmediafilms.com/casestudies/category/branded-series">&mdash; Branded Series</option>
  208. <option value="http://www.magnetmediafilms.com/casestudies/category/customer-stories">&mdash; Customer stories</option>
  209. <option value="http://www.magnetmediafilms.com/casestudies/category/thought-leadership">&mdash; Thought Leadership</option>
  210. <option value="http://www.magnetmediafilms.com/casestudies/category/event-based-videos">&mdash; Event-Based Videos</option>
  211. <option value="http://www.magnetmediafilms.com/casestudies/category/social-media-interactive">Social Media &amp; Interactive</option>
  212. <option value="http://www.magnetmediafilms.com/casestudies/category/strategic-consultation">&mdash; Strategic Consultation</option>
  213. <option value="http://www.magnetmediafilms.com/casestudies/category/blogs">&mdash; Corporate Blog Program</option>
  214. <option value="http://www.magnetmediafilms.com/casestudies/category/socially-enabled-microsites">&mdash; Socially Enabled Microsites</option>
  215. <option value="http://www.magnetmediafilms.com/casestudies/category/social-app-development">&mdash; Social App Development</option>
  216. <?php
  217. /*$categories= get_categories( array('hide_empty'=>1) );
  218. foreach ($categories as $category)
  219. {
  220. $option = '<option value="http://www.magnetmediafilms.com/casestudies/category/'.$category->category_nicename.'">';
  221. $option .= $category->cat_name;
  222. $option .= '</option>';
  223. echo $option;
  224. }*/
  225. ?>
  226. </select>
  227. </div>
  228. <? }
  229. function previous_text(){
  230. #$previous = '<span style="font-size: 20px;">«</span> Previous Case Studies';
  231. $previous = 'Next Case Studies <span style="font-size: 20px;">»</span>';
  232. return $previous;
  233. }
  234. add_filter('thesis_previous','previous_text');
  235. function next_text(){
  236. $previous = '<span style="font-size: 20px;">«</span> Previous Case Studies';
  237. #$previous = 'Next Case Studies <span style="font-size: 20px;">»</span>';
  238. return $previous;
  239. }
  240. add_filter('thesis_next','next_text');
  241. add_action('thesis_hook_after_content_area', 'div_push');
  242. add_action('thesis_hook_before_html', 'div_wrapper_start');
  243. add_action('thesis_hook_after_content_area', 'div_wrapper_close');
  244. // Feature box slider
  245. if (function_exists('camera_main_ss_add')) {
  246. add_action('admin_init','camera_main_ss_add');
  247. }
  248. function custom_feature_box(){
  249. if (function_exists('camera_meta_slideshow'))
  250. {
  251. $meta_camera = get_post_custom( get_the_ID() );
  252. if(isset($meta_camera['camera_meta_slideshow'])){
  253. if ( is_home() || is_tag() || is_category() || $meta_camera['camera_meta_slideshow'][0] === 'none' )
  254. {
  255. echo camera_meta_slideshow('homepage');
  256. }
  257. else
  258. {
  259. echo camera_meta_slideshow($meta_camera['camera_meta_slideshow'][0]);
  260. }
  261. }
  262. }
  263. }
  264. add_action('thesis_hook_feature_box', 'custom_feature_box');
  265. // Remove sidebars on home page
  266. function no_sidebars() {
  267. if (is_home())
  268. return false;
  269. else
  270. return false;
  271. }
  272. add_filter('thesis_show_sidebars', 'no_sidebars');
  273. // Add a custom class to home page for styling
  274. function home_body_class($classes) {
  275. if (is_home()) {
  276. $classes[] .= 'home';
  277. }
  278. return $classes;
  279. }
  280. add_filter('thesis_body_classes', 'home_body_class');
  281. add_theme_support('post-thumbnails');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement