Tahir-Support

Search.php with Portfolio External url fix .

Apr 12th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. <?php get_header(); ?>
  2.  
  3. <script>
  4. jQuery(document).ready(function($){
  5.  
  6. var $searchContainer = $('#search-results');
  7.  
  8. $(window).load(function(){
  9.  
  10. $searchContainer.isotope({
  11. itemSelector: '.result',
  12. layoutMode: 'packery',
  13. packery: { columnWidth: $('#search-results').width() / 3 }
  14. });
  15.  
  16. $searchContainer.css('visibility','visible');
  17.  
  18. });
  19.  
  20. $(window).resize(function(){
  21. $searchContainer.isotope({
  22. layoutMode: 'packery',
  23. packery: { columnWidth: $('#search-results').width() / 3}
  24. });
  25. });
  26.  
  27.  
  28. });
  29. </script>
  30.  
  31. <div class="container-wrap">
  32.  
  33. <div class="container main-content">
  34.  
  35. <div class="row">
  36. <div class="col span_12">
  37. <div class="col span_12 section-title">
  38. <h1><?php echo __('Results For', NECTAR_THEME_NAME); ?><span>"<?php echo esc_html( get_search_query( false ) ); ?>"</span></h1>
  39. </div>
  40. </div>
  41. </div>
  42.  
  43. <div class="divider"></div>
  44.  
  45. <div class="row">
  46.  
  47. <div class="col span_9">
  48.  
  49. <div id="search-results">
  50.  
  51. <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
  52.  
  53.  
  54.  
  55. <?php if( get_post_type($post->ID) == 'post' ){ ?>
  56. <article class="result">
  57. <div class="inner-wrap">
  58. <span class="bottom-line"></span>
  59. <?php if(has_post_thumbnail( $post->ID )) {
  60. echo '<a href="'.get_permalink().'">'.get_the_post_thumbnail($post->ID, 'full', array('title' => '')).'</a>';
  61. } ?>
  62. <h2 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <span><?php echo __('Blog Post', NECTAR_THEME_NAME); ?></span></h2>
  63. </div>
  64. </article><!--/search-result-->
  65. <?php }
  66.  
  67. else if( get_post_type($post->ID) == 'page' ){ ?>
  68. <article class="result">
  69. <div class="inner-wrap">
  70. <span class="bottom-line"></span>
  71. <h2 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <span><?php echo __('Page', NECTAR_THEME_NAME); ?></span></h2>
  72.  
  73. <?php if(has_excerpt()) the_excerpt(); ?>
  74. </div>
  75. </article><!--/search-result-->
  76. <?php }
  77.  
  78. else if( get_post_type($post->ID) == 'portfolio' ){ ?>
  79. <article class="result">
  80. <div class="inner-wrap">
  81. <span class="bottom-line"></span>
  82.  
  83. <?php
  84. $custom_project_link = get_post_meta($post->ID, '_nectar_external_project_url', true);
  85. $the_project_link = (!empty($custom_project_link)) ? $custom_project_link : get_permalink();
  86. console.log($the_project_link);
  87.  
  88. if(has_post_thumbnail( $post->ID )) {
  89. echo '<a href="'.$the_project_link.'">'.get_the_post_thumbnail($post->ID, 'full', array('title' => '')).'</a>';
  90. } ?>
  91.  
  92.  
  93.  
  94. <h2 class="title"><a href="<?php echo $the_project_link; ?>"><?php the_title(); ?></a> <span><?php echo __('Portfolio Item', NECTAR_THEME_NAME); ?></span></h2>
  95. </div>
  96. </article><!--/search-result-->
  97. <?php }
  98.  
  99. else if( get_post_type($post->ID) == 'product' ){ ?>
  100. <article class="result">
  101. <div class="inner-wrap">
  102. <span class="bottom-line"></span>
  103. <?php if(has_post_thumbnail( $post->ID )) {
  104. echo '<a href="'.get_permalink().'">'. get_the_post_thumbnail($post->ID, 'full', array('title' => '')).'</a>';
  105. } ?>
  106. <h2 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <span><?php echo __('Product', NECTAR_THEME_NAME); ?></span></h2>
  107. </div>
  108. </article><!--/search-result-->
  109. <?php } else { ?>
  110. <article class="result">
  111. <div class="inner-wrap">
  112. <span class="bottom-line"></span>
  113. <?php if(has_post_thumbnail( $post->ID )) {
  114. echo '<a href="'.get_permalink().'">'.get_the_post_thumbnail($post->ID, 'full', array('title' => '')).'</a>';
  115. } ?>
  116. <h2 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  117. </div>
  118. </article><!--/search-result-->
  119. <?php } ?>
  120.  
  121.  
  122.  
  123. <?php endwhile;
  124.  
  125. else: echo "<p>" . __('No results found', NECTAR_THEME_NAME) . "</p>"; endif;?>
  126.  
  127.  
  128. </div><!--/search-results-->
  129.  
  130.  
  131. <?php if( get_next_posts_link() || get_previous_posts_link() ) { ?>
  132. <div id="pagination">
  133. <div class="prev"><?php previous_posts_link('&laquo; Previous Entries') ?></div>
  134. <div class="next"><?php next_posts_link('Next Entries &raquo;','') ?></div>
  135. </div>
  136. <?php }?>
  137.  
  138. </div><!--/span_9-->
  139.  
  140. <div id="sidebar" class="col span_3 col_last">
  141. <?php get_sidebar(); ?>
  142. </div><!--/span_3-->
  143.  
  144. </div><!--/row-->
  145.  
  146. </div><!--/container-->
  147.  
  148. </div><!--/container-wrap-->
  149.  
  150. <?php get_footer(); ?>
Add Comment
Please, Sign In to add comment