예제 #1
0
파일: blog.php 프로젝트: iq007/MadScape
?>

				<?php 
global $post, $paged, $more;
$more = 0;
if (get_query_var('paged')) {
    $paged = get_query_var('paged');
} else {
    if (get_query_var('page')) {
        $paged = get_query_var('page');
    } else {
        $paged = 1;
    }
}
// Query posts
$wp_query = new WP_Query(array('post_type' => 'post', 'paged' => $paged, 'category__not_in' => wpex_blog_exclude_categories(true)));
if ($wp_query->posts) {
    ?>

					<div id="blog-entries" class="clr <?php 
    wpex_blog_wrap_classes();
    ?>
">
						<?php 
    $wpex_count = 0;
    ?>
						<?php 
    while (have_posts()) {
        the_post();
        ?>
							<?php 
예제 #2
0
 /**
  * Pre get posts functions
  */
 function pre_get_posts()
 {
     // Exclude categories from the blog
     if (function_exists('wpex_blog_exclude_categories')) {
         wpex_blog_exclude_categories();
     }
 }
예제 #3
0
 /**
  * This function runs before the main query.
  *
  * @since 1.6.0
  */
 public function pre_get_posts($query)
 {
     // Lets not break stuff
     if (is_admin() || !$query->is_main_query()) {
         return;
     }
     // Search pagination
     if (is_search()) {
         $query->set('posts_per_page', wpex_get_mod('search_posts_per_page', '10'));
         return;
     }
     // Exclude categories from the main blog
     if ((is_home() || is_page_template('templates/blog.php')) && ($cats = wpex_blog_exclude_categories())) {
         set_query_var('category__not_in', $cats);
         return;
     }
     // Category pagination
     $terms = get_terms('category');
     if (!empty($terms)) {
         foreach ($terms as $term) {
             if (is_category($term->slug)) {
                 $term_id = $term->term_id;
                 $term_data = get_option("category_{$term_id}");
                 if ($term_data) {
                     if (!empty($term_data['wpex_term_posts_per_page'])) {
                         $query->set('posts_per_page', $term_data['wpex_term_posts_per_page']);
                         return;
                     }
                 }
             }
         }
     }
 }