Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Template for Featured Content Page to override parent theme's function
- */
- function catchkathmandu_featured_content_page( $options ) {
- global $post;
- $quantity = $options [ 'homepage_featured_qty' ];
- $headline = $options [ 'homepage_featured_headline' ];
- $layouts = $options [ 'homepage_featured_layout' ];
- $number_of_post = 0; // for number of posts
- $post_list = array(); // list of valid post ids
- $featured_content = '';
- //Get valid number of posts
- for( $i = 1; $i <= $quantity; $i++ ){
- if( isset ( $options[ 'featured_content_page' ][ $i ] ) && $options[ 'featured_content_page' ][ $i ] > 0 ) {
- $number_of_post++;
- $post_list = array_merge( $post_list, array( $options[ 'featured_content_page' ][ $i ] ) );
- }
- }
- //Checking Layout
- if ( $layouts == 'four-columns' ) {
- $classes = "layout-four";
- }
- else {
- $classes = "layout-three";
- }
- if ( !empty( $post_list ) && $number_of_post > 0 ) {
- $get_featured_posts = new WP_Query( array(
- 'posts_per_page' => $number_of_post,
- 'post__in' => $post_list,
- 'orderby' => 'post__in',
- 'post_type' => 'page',
- ));
- $i=0;
- $featured_content .= '<section id="featured-post" class="featured-content-page ' . $classes . '">';
- if ( !empty( $headline ) ) {
- $featured_content .= '<h1 id="feature-heading" class="entry-title">' . $headline . '</h1>';
- }
- $featured_content .= '<div class="featued-content-wrap">';
- while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
- $title_attribute = the_title_attribute( array( 'before' => __( 'Permalink to:', 'catch-kathmandu' ), 'echo' => false ) );
- $excerpt = get_the_excerpt();
- $featured_content .= '
- <article id="featured-post-' . $i . '" class="post hentry">';
- if ( has_post_thumbnail() ) {
- $featured_content .= '
- <figure class="featured-homepage-image">
- <a href="' . get_permalink() . '" title="' . the_title_attribute( array( 'before' => __( 'Permalink to:', 'catch-kathmandu' ), 'echo' => false ) ) . '">
- '. get_the_post_thumbnail( $post->ID, 'small-featured', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ) .'
- </a>
- </figure>';
- }
- else {
- $catchkathmandu_first_image = catchkathmandu_get_first_image( $post->ID, 'small-featured', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) );
- if ( '' != $catchkathmandu_first_image ) {
- $featured_content .= '
- <figure class="featured-homepage-image">
- <a href="' . esc_url( get_permalink() ) . '" title="' . the_title_attribute( array( 'before' => __( 'Permalink to:', 'catch-kathmandu' ), 'echo' => false ) ) . '">
- '. $catchkathmandu_first_image .'
- </a>
- </figure>';
- }
- }
- $featured_content .= '
- <div class="entry-container">';
- $featured_content .= '<a href="' . esc_url( get_permalink() ) . '" title="' . the_title_attribute( array( 'before' => __( 'Permalink to:', 'catch-kathmandu' ), 'echo' => false ) ) . '">
- '. the_title( '<header class="entry-header"><h1 class="entry-title">','</h1></header>', false ) .'
- </a>';
- $content = apply_filters( 'the_content', get_the_content() );
- $content = str_replace( ']]>', ']]>', $content );
- $featured_content .= '<div class="entry-content">'.$content.'</div>';
- $featured_content .= '<a href="' . get_permalink() . '" title="' . the_title_attribute( array( 'before' => __( 'Permalink to:', 'catch-kathmandu' ), 'echo' => false ) ) . '"></a>';
- $featured_content .= '
- </div><!-- .entry-container -->
- </article><!-- .featured-post-'. $i .' -->';
- endwhile;
- wp_reset_query();
- $featured_content .= '</div><!-- .featued-content-wrap -->';
- $featured_content .= '</section><!-- #featured-post -->';
- }
- return $featured_content;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement