Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Conditionally break posts into 2 columns with featured posts on first page
- add_filter( 'post_class', 'be_archive_post_class' );
- function be_archive_post_class( $classes ) {
- if ( is_home() ) {
- global $wp_query;
- $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
- // Check if on first page of pagination
- if ( 1 == $paged ) {
- if ( 1 >= $wp_query->current_post ) {
- // Don't add a class to first and second posts
- $classes[] = '';
- } else {
- // Add .one-half to all posts besides first and second
- $classes[] = 'one-half';
- }
- // Skip the first and second posts and add .first to every other
- if ( 0 == $wp_query->current_post % 2 ) {
- $classes[] = 'first';
- }
- } else {
- // On all other pages add .one-half to all posts
- $classes[] = 'one-half';
- // Add .first to every other post
- if ( 0 == $wp_query->current_post % 2 ) {
- $classes[] = 'first';
- }
- }
- }
- return $classes;
- }
- add_action( 'genesis_before_loop', 'sk_custom_content_display' );
- /**
- * Show full content for first 2 posts on first page
- * and exerpts/content per Content Archives settings on paginated pages (second, third and so on..).
- *
- * Scope: Posts page and all archives.
- *
- * @author Sridhar Katakam
- * @link http://sridharkatakam.com/show-full-content-first-2-posts-first-page-posts-page-archives-genesis/
- */
- function sk_custom_content_display() {
- if ( is_home() && ! is_paged() ) {
- add_filter( 'genesis_pre_get_option_content_archive_thumbnail', 'sk_return_zero' );
- add_filter( 'genesis_pre_get_option_content_archive', 'sk_return_full' );
- add_filter( 'genesis_pre_get_option_content_archive_limit', 'sk_return_zero' );
- }
- }
- function sk_return_zero() {
- global $wp_query;
- if ( ( $wp_query->current_post <= 1 ) ) {
- return '0';
- }
- }
- function sk_return_full() {
- global $wp_query;
- if ( ( $wp_query->current_post <= 1 ) ) {
- return 'full';
- }
- }
- add_action( 'pre_get_posts', 'be_change_event_posts_per_page' );
- /**
- * Change Posts Per Page for Event Archive
- *
- * @author Bill Erickson
- * @link http://www.billerickson.net/customize-the-wordpress-query/
- * @param object $query data
- *
- */
- function be_change_event_posts_per_page( $query ) {
- if( $query->is_main_query() && !is_admin() && is_home() ) {
- $query->set( 'posts_per_page', '8' );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement