/** * Exclude posts that belong to the categories displayed in slider from the posts listing */ function graphene_exclude_slider_categories($request) { global $graphene_settings, $graphene_defaults; if ($graphene_settings['slider_type'] != 'categories') { return $request; } if (is_admin()) { return $request; } if ($graphene_settings['slider_exclude_categories'] != $graphene_defaults['slider_exclude_categories']) { $dummy_query = new WP_Query(); $dummy_query->parse_query($request); if (get_option('show_on_front') == 'page' && $dummy_query->query_vars['page_id'] == get_option('page_on_front')) { return $request; } if ($graphene_settings['slider_exclude_categories'] == 'everywhere' || $graphene_settings['slider_exclude_categories'] == 'homepage' && $dummy_query->is_home()) { $request['category__not_in'] = graphene_object_id($graphene_settings['slider_specific_categories'], 'category'); } } return $request; }
/** * Only show posts from specific category in the front page */ function graphene_filter_posts_category($query) { if (!($query->is_home() && $query->is_main_query())) { return; } global $graphene_settings; if (empty($graphene_settings['frontpage_posts_cats']) || in_array('disabled', $graphene_settings['frontpage_posts_cats'])) { return; } $cats = $graphene_settings['frontpage_posts_cats']; $query->set('category__in', graphene_object_id($cats, 'category')); }
/** * Adds the content panes in the homepage. The homepage panes are only displayed if using a static * front page, before the comments. It is also recommended that the comments section is disabled * for the page used as the static front page. */ function graphene_homepage_panes() { global $graphene_settings, $graphene_defaults, $in_homepage_panes; $in_homepage_panes = true; // Get the number of panes to display if ($graphene_settings['show_post_type'] == 'latest-posts' || $graphene_settings['show_post_type'] == 'cat-latest-posts') { $pane_count = $graphene_settings['homepage_panes_count']; } elseif ($graphene_settings['show_post_type'] == 'posts') { $pane_count = count(explode(',', $graphene_settings['homepage_panes_posts'])); } // Build the common WP_Query() parameter first $args = array('orderby' => 'date', 'order' => 'DESC', 'post_type' => array('post', 'page'), 'posts_per_page' => $pane_count, 'ignore_sticky_posts' => 1); // args specific to latest posts if ($graphene_settings['show_post_type'] == 'latest-posts') { $args_merge = array('post_type' => array('post')); $args = array_merge($args, $args_merge); } // args specific to latest posts by category if ($graphene_settings['show_post_type'] == 'cat-latest-posts') { $args_merge = array('category__in' => graphene_object_id($graphene_settings['homepage_panes_cat'], 'category')); $args = array_merge($args, $args_merge); } // args specific to posts/pages if ($graphene_settings['show_post_type'] == 'posts') { $post_ids = $graphene_settings['homepage_panes_posts']; $post_ids = preg_split("/[\\s]*[,][\\s]*/", $post_ids, -1, PREG_SPLIT_NO_EMPTY); // post_ids are comma seperated, the query needs a array $post_ids = graphene_object_id($post_ids); $args_merge = array('post__in' => $post_ids, 'orderby' => 'post__in'); $args = array_merge($args, $args_merge); } // Get the posts to display as homepage panes $panes = new WP_Query(apply_filters('graphene_homepage_panes_args', $args)); $count = 0; ?> <?php do_action('graphene_before_homepage_panes'); ?> <div class="homepage_panes"> <?php while ($panes->have_posts()) { $panes->the_post(); $count++; $alpha = $omega = false; if ($count % 2) { $alpha = true; } else { $omega = true; } ?> <div <?php graphene_grid('homepage_pane clearfix', 8, 5, 4, $alpha, $omega); ?> id="homepage-pane-<?php the_ID(); ?> "> <?php do_action('graphene_homepage_pane_top'); ?> <a href="<?php the_permalink(); ?> " title="<?php printf(__('Permalink to %s', 'graphene'), esc_attr(get_the_title())); ?> "> <?php /* Get the post's image */ if (has_post_thumbnail(get_the_ID())) { $image = get_the_post_thumbnail(get_the_ID(), 'graphene-homepage-pane'); } else { $image = graphene_get_post_image(get_the_ID(), 'graphene-homepage-pane', 'excerpt'); } if ($image) { echo apply_filters('graphene_homepage_pane_image', $image, get_the_ID()); } ?> </a> <?php /* The post title */ ?> <h3 class="post-title"> <a href="<?php the_permalink(); ?> " title="<?php printf(__('Permalink to %s', 'graphene'), esc_attr(get_the_title())); ?> "><?php the_title(); ?> </a> <?php do_action('homepage_pane_title'); ?> </h3> <?php /* The post excerpt */ ?> <div class="post-excerpt"> <?php the_excerpt(); do_action('graphene_homepage_pane_content'); ?> </div> <?php /* Read more button */ ?> <p class="post-comments"> <a href="<?php the_permalink(); ?> " title="<?php printf(__('Permalink to %s', 'graphene'), esc_attr(get_the_title())); ?> " class="block-button"><?php _e('Read more', 'graphene'); ?> </a> </p> <?php do_action('graphene_homepage_pane_bottom'); ?> </div> <?php } wp_reset_postdata(); ?> </div> <?php do_action('graphene_after_homepage_panes'); unset($in_homepage_panes); }