Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- $output = '';
- //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 ( 'four-columns' == $layouts ) {
- $classes = "layout-four";
- }
- else {
- $classes = "layout-three";
- }
- if ( !empty( $post_list ) && $number_of_post > 0 ) {
- $loop = new WP_Query( array(
- 'posts_per_page' => $number_of_post,
- 'post__in' => $post_list,
- 'orderby' => 'post__in',
- 'post_type' => 'page',
- ));
- $i=0;
- $output .= '<section id="featured-post" class="featured-content-page ' . $classes . '">';
- if ( !empty( $headline ) ) {
- $output .= '<h1 id="feature-heading" class="entry-title">' . wp_kses_post( $headline ) . '</h1>';
- }
- $output .= '<div class="featued-content-wrap">';
- while ( $loop->have_posts()) : $loop->the_post(); $i++;
- $title_attribute = the_title_attribute( 'echo=0' );
- $content = get_the_content();
- $output .= '
- <article id="featured-post-' . $i . '" class="post hentry">';
- if ( has_post_thumbnail() ) {
- $output .= '
- <figure class="featured-homepage-image">
- <a href="' . esc_url( get_permalink() ) . '" title="' . $title_attribute . '">
- '. get_the_post_thumbnail( $post->ID, 'small-featured', array( 'title' => $title_attribute, 'alt' => $title_attribute, 'class' => 'pngfix' ) ) .'
- </a>
- </figure>';
- }
- else {
- $catchkathmandu_first_image = catchkathmandu_get_first_image( $post->ID, 'small-featured', array( 'title' => $title_attribute, 'alt' => $title_attribute, 'class' => 'pngfix' ) );
- if ( '' != $catchkathmandu_first_image ) {
- $output .= '
- <figure class="featured-homepage-image">
- <a href="' . esc_url( get_permalink() ) . '" title="' . $title_attribute . '">
- '. $catchkathmandu_first_image .'
- </a>
- </figure>';
- }
- }
- $output .= '
- <div class="entry-container">';
- if ( $content !='') {
- $output .= the_title( '<header class="entry-header"><h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" title="' . $title_attribute . '">','</a></h1></header>', false );
- $output .= '<div class="entry-content">' . do_shortcode( $content ) . '</div>';
- $output .= '<a href="' . esc_url( get_permalink() ) . '" title="' . $title_attribute . '"></a>';
- }
- $output .= '
- </div><!-- .entry-container -->
- </article><!-- .featured-post-'. $i .' -->';
- endwhile;
- wp_reset_postdata();
- $output .= '</div><!-- .featued-content-wrap -->';
- $output .= '</section><!-- #featured-post -->';
- }
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement