Advertisement
pratikshrestha

Simple Catch: Remove Post Links

Apr 5th, 2016
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.62 KB | None | 0 0
  1. /**
  2.  * This function displays featured posts on homepage header without the links by overriding parent function
  3.  */
  4. function simplecatch_sliders() {
  5.     //delete_transient( 'simplecatch_sliders' );
  6.  
  7.     global $post, $simplecatch_options_settings;
  8.     $options = $simplecatch_options_settings;
  9.  
  10.     $postperpage = $options[ 'slider_qty' ];
  11.     $slidereffect = $options[ 'remove_noise_effect' ];
  12.  
  13.     if( ( !$simplecatch_sliders = get_transient( 'simplecatch_sliders' ) ) && !empty( $options[ 'featured_slider' ] ) ) {
  14.         echo '<!-- refreshing cache -->';
  15.  
  16.         $simplecatch_sliders = '
  17.         <div id="main-slider" class="post-slider">
  18.             <section class="featured-slider">';
  19.                 $get_featured_posts = new WP_Query( array(
  20.                     'posts_per_page' => $postperpage,
  21.                     'post__in'       => $options[ 'featured_slider' ],
  22.                     'orderby'        => 'post__in',
  23.                     'ignore_sticky_posts' => 1 // ignore sticky posts
  24.                 ));
  25.  
  26.                 $i=0; while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
  27.                     $title_attribute = apply_filters( 'the_title', get_the_title( $post->ID ) );
  28.                     $excerpt = get_the_excerpt();
  29.                     if ( $i == 1 ) { $classes = "slides displayblock"; } else { $classes = "slides displaynone"; }
  30.                     $simplecatch_sliders .= '
  31.                     <div class="'.$classes.'">
  32.                         <div class="featured-img">';
  33.                             if( has_post_thumbnail() ) {
  34.  
  35.                                 $simplecatch_sliders .= '<a href="javascript:void(0);" title="Permalink to '.the_title('','',false).'">';
  36.  
  37.                                 if( $slidereffect == "0" ) {
  38.                                     $simplecatch_sliders .= '<span class="img-effect pngfix"></span>';
  39.                                 }
  40.  
  41.                                 $simplecatch_sliders .= '<figure>'.get_the_post_thumbnail( $post->ID, 'slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class'  => 'pngfix' ) ).'</figure></a>';
  42.                             }
  43.                             else {
  44.                                 $simplecatch_sliders .= '<span class="img-effect pngfix"></span>';
  45.                             }
  46.                             $simplecatch_sliders .= '
  47.                         </div> <!-- .featured-image -->
  48.                         <article class="featured-text">';
  49.                             if( $excerpt !='') {
  50.                                 $simplecatch_sliders .= the_title( '<span class="slider-title">','</span>', false ).'<span class="slider-sep">: </span><span class="slider-content">'.$excerpt.'</span>';
  51.                             }
  52.                             $simplecatch_sliders .= '
  53.                         </article><!-- .featured-text -->
  54.                     </div> <!-- .slides -->';
  55.                 endwhile; wp_reset_query();
  56.  
  57.             $simplecatch_sliders .= '
  58.             </section> <!-- .featured-slider -->
  59.             <div id="controllers">
  60.             </div><!-- #controllers -->
  61.         </div><!-- #main-slider -->';
  62.  
  63.         set_transient( 'simplecatch_sliders', $simplecatch_sliders, 86940 );
  64.     }
  65.     echo $simplecatch_sliders;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement