Created
April 27, 2017 13:46
-
-
Save samikeijonen/1258da401f413ab30b54cf89d8460acc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Featured areas in Front Page Template. This file is called in footer.php. | |
* | |
* @package Munsa | |
*/ | |
?> | |
<div id="featured-area" class="featured-area"> | |
<?php | |
// Blog Posts Query. | |
$blog_content = new WP_Query( apply_filters( 'munsa_blog_posts_arguments', array( | |
'post_type' => 'post', | |
'posts_per_page' => 3, | |
'no_found_rows' => true, | |
) ) ); | |
// Get featured pages. | |
$munsa_featured_pages = munsa_featured_pages(); | |
// Check if there is content we want to show. | |
if ( $blog_content->have_posts() || ! empty( $munsa_featured_pages ) ) : | |
// Check do we have featured pages. This function returns page ID:s in an array. | |
if ( ! empty( $munsa_featured_pages ) ) : | |
?> | |
<div id="featured-pages-area" class="featured-pages-area front-page-area"> | |
<div class="featured-pages-wrapper"> | |
<?php | |
$page = 1; | |
foreach ( $munsa_featured_pages as $munsa_page_id ) : // Begins the loop through found pages from customize settings. ?> | |
<?php $munsa_bg = munsa_get_post_thumbnail( $post_thumbnail = 'munsa-medium', $id = $munsa_page_id )?> | |
<article id="post-<?php echo $munsa_page_id; ?>" <?php post_class( $class = '', $post_id = $munsa_page_id ); ?> <?php hybrid_attr( 'post' ); ?>> | |
<div class="entry-wrapper"> | |
<?php | |
// If fourth page, use category link. | |
if ( 4 === $page ) : | |
$page_link = get_category_link( 19 ); | |
else : | |
$page_link = get_permalink( $munsa_page_id ); | |
endif; | |
?> | |
<a href="<?php echo esc_url( $page_link ); ?>" rel="bookmark"> | |
<div class="entry-bg-image"<?php if ( has_post_thumbnail( $munsa_page_id ) ) echo ' style="background-image:url(' . esc_url( $munsa_bg ) . ');"' ?>> | |
<header class="entry-header"> | |
<h2 class="entry-title" <?php echo hybrid_get_attr( 'entry-title' ); ?>><?php echo get_the_title( $munsa_page_id ); ?></h2> | |
</header><!-- .entry-header --> | |
</div><!-- .entry-bg-image --> | |
</a> | |
</div><!-- .entry-wrapper --> | |
</article><!-- .post-## --> | |
<?php | |
$page++; | |
endforeach; ?> | |
</div><!-- .featured-pages-wrapper --> | |
</div><!-- .featured-pages-area --> | |
<?php endif; // End check for featured pages. ?> | |
<?php if ( $blog_content->have_posts() ) : ?> | |
<div id="blog-content-area" class="blog-content-area front-page-area"> | |
<div class="blog-wrapper"> | |
<?php // Blog area title and link. | |
if( get_theme_mod( 'blog_area_title', esc_html__( 'Articles', 'munsa' ) ) || ( get_theme_mod( 'blog_area_url' ) && get_theme_mod( 'blog_area_url_text' ) ) ) : | |
echo '<div class="blog-title-wrapper">'; | |
// Featured are title. | |
if( get_theme_mod( 'blog_area_title', esc_html__( 'Articles', 'munsa' ) ) ) : | |
echo '<h2 class="blog-title entry-title">' . esc_html( get_theme_mod( 'blog_area_title', esc_html__( 'Articles', 'munsa' ) ) ) . '</h2>'; | |
endif; | |
// Featured are link | |
if( get_theme_mod( 'blog_area_url' ) && get_theme_mod( 'blog_area_url_text' ) ) : | |
echo '<a class="munsa-button blog-link" href="' . esc_url( get_theme_mod( 'blog_area_url' ) ) . '">' . esc_html( get_theme_mod( 'blog_area_url_text' ) ) . '</a>'; | |
endif; | |
echo '</div><!-- .blog-title-wrapper -->'; | |
endif; // End featured are title and link | |
?> | |
<div class="blog-posts-wrapper" itemscope="itemscope" itemtype="http://schema.org/Blog"> | |
<?php while ( $blog_content->have_posts() ) : $blog_content->the_post(); ?> | |
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php hybrid_attr( 'post' ); ?>> | |
<?php if ( has_post_thumbnail() ) : ?> | |
<a class="post-thumbnail" href="<?php the_permalink(); ?>"> | |
<?php the_post_thumbnail( 'munsa-smaller', array( 'alt' => the_title_attribute( 'echo=0' ) ) ); ?> | |
</a> | |
<?php endif; ?> | |
<header class="entry-header"> | |
<?php the_title( sprintf( '<h3 class="entry-title" ' . hybrid_get_attr( 'entry-title' ) . '><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' ); ?> | |
<?php get_template_part( 'entry', 'meta' ); // Loads the entry-meta.php template. ?> | |
</header><!-- .entry-header --> | |
</article><!-- #post-## --> | |
<?php endwhile; ?> | |
</div><!-- .blog-posts-wrapper --> | |
</div><!-- .blog-wrapper --> | |
</div><!-- .blog-content-area --> | |
<?php | |
endif; // End loop. | |
wp_reset_postdata(); // Reset post data. | |
?> | |
<?php if ( $munsa_has_contact_info = munsa_has_contact_info() && ! get_theme_mod( 'hide_from_front_page' ) ) : ?> | |
<div id="contact-content-area" class="contact-content-area front-page-area"> | |
<div class="contact-wrapper"> | |
<?php munsa_contact_info(); // This function is in inc/template-tags.php file. ?> | |
</div><!-- .contact-wrapper --> | |
</div><!-- .contact-content-area --> | |
<?php endif; ?> | |
<?php elseif( current_user_can( 'publish_posts' ) ) : // If there are no content ?> | |
<p class="no-content"> | |
<?php printf( wp_kses( __( 'Set Front Page Template content in the Customizer. Or <a href="%1$s">publish your first post here</a>.', 'munsa' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( admin_url( 'post-new.php' ) ) ); ?> | |
</p> | |
<?php endif; ?> | |
</div><!-- .featured-area --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment