Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function catchbase_page_content( $options ) {
- global $post;
- $quantity = $options [ 'featured_content_number' ];
- $more_link_text = $options['excerpt_more_text'];
- $show_content = isset( $options['featured_content_show'] ) ? $options['featured_content_show'] : 'excerpt';
- $catchbase_page_content = '';
- $number_of_page = 0; // for number of pages
- $page_list = array(); // list of valid pages ids
- //Get valid pages
- for( $i = 1; $i <= $quantity; $i++ ){
- if( isset ( $options['featured_content_page_' . $i] ) && $options['featured_content_page_' . $i] > 0 ){
- $number_of_page++;
- $page_list = array_merge( $page_list, array( $options['featured_content_page_' . $i] ) );
- }
- }
- if ( !empty( $page_list ) && $number_of_page > 0 ) {
- $get_featured_posts = new WP_Query( array(
- 'posts_per_page' => $number_of_page,
- 'post__in' => $page_list,
- 'orderby' => 'post__in',
- 'post_type' => 'page',
- ));
- $i=0;
- while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++;
- $title_attribute = the_title_attribute( array( 'before' => __( 'Permalink to:', 'catch-base' ), 'echo' => false ) );
- $excerpt = get_the_excerpt();
- $catchbase_page_content .= '
- <article id="featured-post-' . $i . '" class="post hentry featured-page-content">';
- if ( has_post_thumbnail() ) {
- $catchbase_page_content .= '
- <figure class="featured-homepage-image">
- <a href="' . get_permalink() . '" title="' . the_title_attribute( array( 'before' => __( 'Permalink to:', 'catch-base' ), 'echo' => false ) ) . '">
- '. get_the_post_thumbnail( $post->ID, 'medium', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ) .'
- </a>
- </figure>';
- }
- else {
- $catchbase_first_image = catchbase_get_first_image( $post->ID, 'medium', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) );
- if ( '' != $catchbase_first_image ) {
- $catchbase_page_content .= '
- <figure class="featured-homepage-image">
- <a href="' . get_permalink() . '" title="' . the_title_attribute( array( 'before' => __( 'Permalink to:', 'catch-base' ), 'echo' => false ) ) . '">
- '. $catchbase_first_image .'
- </a>
- </figure>';
- }
- }
- $catchbase_page_content .= '
- <div class="entry-container">
- <header class="entry-header">
- <h1 class="entry-title">
- ' . the_title( '','', false ) . '
- </h1>
- </header>';
- if ( 'excerpt' == $show_content ) {
- $catchbase_page_content .= '<div class="entry-excerpt"><p>' . $excerpt . '</p></div><!-- .entry-excerpt -->';
- }
- elseif ( 'full-content' == $show_content ) {
- $content = apply_filters( 'the_content', get_the_content() );
- $content = str_replace( ']]>', ']]>', $content );
- $catchbase_page_content .= '<div class="entry-content">' . $content . '</div><!-- .entry-content -->';
- }
- $catchbase_page_content .= '
- </div><!-- .entry-container -->
- </article><!-- .featured-post-'. $i .' -->';
- endwhile;
- wp_reset_query();
- }
- return $catchbase_page_content;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement