Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WP Theme: Hueman
- Display the static Front page using the Standard Blog List layout, and the blog Home page using the default post list layout
- *******************************************************************************************************************
- <!-- front-page.php
- This is a copy of index.php with the following changes:
- 1. the main loop is replaced with a custom query
- 2. added a query reset after the loop is processed
- -->
- <?php get_header(); ?>
- <section class="content">
- <?php get_template_part('inc/page-title'); ?>
- <div class="pad group">
- <?php get_template_part('inc/featured'); ?>
- <!-- if there are featured posts and they aren't included in the post previews -->
- <?php if ( ot_get_option('featured-posts-count') != '0' && ( !ot_get_option('featured-posts-include') ) ): ?>
- <?php $featured_post_ids = get_featured_post_ids(); ?>
- <?php $args = array( 'post_type'=>'post', 'post__not_in'=>$featured_post_ids ); ?>
- <?php else: ?>
- <?php $args = array( 'post_type'=>'post' ); ?>
- <?php endif; ?>
- <?php $frontpage_posts = new WP_query($args); ?>
- <?php if ( $frontpage_posts->have_posts() ) : ?>
- <?php if ( ot_get_option('blog-standard') == 'on' ): ?>
- <?php while ( $frontpage_posts->have_posts() ): $frontpage_posts->the_post(); ?>
- <?php get_template_part('content-standard'); ?>
- <?php endwhile; ?>
- <?php else: ?>
- <div class="post-list group">
- <?php $i = 1; echo '<div class="post-row">'; while ( $frontpage_posts->have_posts() ): $frontpage_posts->the_post(); ?>
- <?php get_template_part('content'); ?>
- <?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
- </div><!--/.post-list-->
- <?php endif; ?>
- <?php get_template_part('inc/pagination'); ?>
- <?php wp_reset_postdata(); ?>
- <?php endif; ?>
- </div><!--/.pad-->
- </section><!--/.content-->
- <?php get_sidebar(); ?>
- <?php get_footer(); ?>
- <!-- End of front-page.php -->
- *******************************************************************************************************************
- <!-- home.php
- This is a copy of index.php with the following changes:
- 1. the featured posts slider has been removed
- 2. the check for blog-standard has been reversed so the page display is the opposite of front-page.php
- -->
- <?php get_header(); ?>
- <section class="content">
- <?php get_template_part('inc/page-title'); ?>
- <div class="pad group">
- <?php if ( have_posts() ) : ?>
- <!-- reverse the criteria so it displays the Standard Post List when the option is OFF -->
- <?php if ( ot_get_option('blog-standard') != 'on' ): ?>
- <?php while ( have_posts() ): the_post(); ?>
- <?php get_template_part('content-standard'); ?>
- <?php endwhile; ?>
- <?php else: ?>
- <div class="post-list group">
- <?php $i = 1; echo '<div class="post-row">'; while ( have_posts() ): the_post(); ?>
- <?php get_template_part('content'); ?>
- <?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
- </div><!--/.post-list-->
- <?php endif; ?>
- <?php get_template_part('inc/pagination'); ?>
- <?php endif; ?>
- </div><!--/.pad-->
- </section><!--/.content-->
- <?php get_sidebar(); ?>
- <?php get_footer(); ?>
- <!-- End of home.php -->
- *******************************************************************************************************************
- In /inc/featured.php change TWO lines
- from this:
- <?php if ( is_home() && !is_paged() && ( ot_get_option('featured-posts-count')
- to this:
- <?php if ( is_front_page() && !is_paged() && ( ot_get_option('featured-posts-count')
- *******************************************************************************************************************
- In /inc/page-title.php, at the top of the file
- change this:
- <?php if ( is_home() ) : ?>
- <h2><?php echo alx_blog_title(); ?></h2>
- to this:
- <!-- add check for_static Front Page -->
- <?php if ( is_home() || is_front_page() ) : ?>
- <h2><?php echo alx_blog_title(); ?></h2>
- *******************************************************************************************************************
- Add these two functions, including the // comment lines, to your child theme functions.php file
- // Since the Blog page doesn't have Featured Posts we need to include all
- // posts on that page. Override default theme pre_get_posts function.
- function alx_pre_get_posts( $query ) {}
- // copy of alx_get_featured_post_ids but it needs to be local
- function get_featured_post_ids() {
- $args = array(
- 'category' => ot_get_option('featured-category'),
- 'numberposts' => ot_get_option('featured-posts-count')
- );
- $posts = get_posts($args);
- if ( !$posts ) return false;
- foreach ( $posts as $post )
- $ids[] = $post->ID;
- return $ids;
- }
- *******************************************************************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement