Beispiel #1
0
get_sidebar('left');
?>

				<!-- CONTENT (start) -->

				<div id="content" class="<?php 
echo themeblvd_get_column_class('content');
?>
 clearfix" role="main">
					<div class="inner">
						<?php 
themeblvd_content_top();
?>

						<?php 
if (themeblvd_is_grid_mode()) {
    ?>

							<!-- HOMEPAGE POST GRID (start) -->

							<div class="primary-post-grid post_grid_paginated post_grid">
								<div class="grid-protection">

									<?php 
    global $more;
    $more = 0;
    $counter = themeblvd_set_att('counter', 1);
    $columns = themeblvd_get_att('columns');
    ?>
									<?php 
    if (have_posts()) {
 /**
  * Make any needed modifications to the main query
  * via pre_get_posts for the homepage or frontpage
  *
  * @since 2.3.0
  *
  * @param WP_Query $q Current WP_Query object at the time of pre_get_posts
  */
 public function pre_get_posts($q)
 {
     if (!$q->is_main_query() || !$q->is_home() && !$q->is_page() && !$q->is_archive()) {
         return;
     }
     // Static frontpage
     if ($q->is_page() && get_option('show_on_front') == 'page' && get_option('page_on_front') == $q->get('page_id')) {
         $templates = apply_filters('themeblvd_paginated_templates', array('template_list.php', 'template_list.php', 'template_builder.php'));
         $template = get_post_meta($q->get('page_id'), '_wp_page_template', true);
         if (in_array($template, $templates) && isset($q->query['paged'])) {
             $q->set('paged', $q->query['paged']);
         }
     }
     // Adjust posts_per_page if framework is in grid mode
     if ($q->is_archive() || $this->is_blog($q)) {
         // Check to make sure we're in grid mode
         if (themeblvd_is_grid_mode()) {
             $key = 'archive';
             if ($this->is_blog($q)) {
                 $key = 'index';
             }
             $columns = themeblvd_get_option("{$key}_grid_columns");
             if (!$columns) {
                 $columns = apply_filters('themeblvd_default_grid_columns', 3);
             }
             $rows = themeblvd_get_option("{$key}_grid_rows");
             if (!$rows) {
                 $rows = apply_filters('themeblvd_default_grid_rows', 4);
             }
             // Posts per page = $columns x $rows
             $q->set('posts_per_page', $columns * $rows);
         }
     }
     // Exclude any categories from posts page
     if ($this->is_blog($q)) {
         $cat = '';
         if (themeblvd_is_grid_mode()) {
             $exclude = themeblvd_get_option('grid_categories');
         } else {
             $exclude = themeblvd_get_option('blog_categories');
         }
         if ($exclude) {
             foreach ($exclude as $key => $value) {
                 if ($value) {
                     $cat .= sprintf('-%s,', $key);
                 }
             }
         }
         if ($cat) {
             $cat = themeblvd_remove_trailing_char($cat, ',');
             $q->set('cat', $cat);
         }
     }
     // Apply pagination fix when homepage custom layout
     // set over home "posts page"
     if (defined('TB_BUILDER_PLUGIN_VERSION') && $q->is_home() && 'custom_layout' == themeblvd_get_option('homepage_content')) {
         // Layout info
         $kayout_name = themeblvd_get_option('homepage_custom_layout');
         $layout_post_id = themeblvd_post_id_by_name($kayout_name, 'tb_layout');
         if ($layout_post_id) {
             $elements = get_post_meta($layout_post_id, 'elements', true);
         }
         // Loop through elements and look for that single
         // paginated element (there can only be one in a layout).
         if (!empty($elements) && is_array($elements)) {
             foreach ($elements as $area) {
                 if (!empty($area) && is_array($area)) {
                     foreach ($area as $element) {
                         switch ($element['type']) {
                             case 'post_grid_paginated':
                                 if (!empty($element['options']['rows']) && !empty($element['options']['columns'])) {
                                     $posts_per_page = intval($element['options']['rows']) * intval($element['options']['columns']);
                                 }
                                 $q->set('posts_per_page', $posts_per_page);
                                 break;
                             case 'post_list_paginated':
                                 if (isset($element['options']['source']) && 'query' == $element['options']['source']) {
                                     if (!empty($element['options']['query'])) {
                                         $custom_q = wp_parse_args(htmlspecialchars_decode($element['options']['query']));
                                     }
                                     if (isset($custom_q['posts_per_page'])) {
                                         $q->set('posts_per_page', $custom_q['posts_per_page']);
                                     }
                                 } else {
                                     if (!empty($element['options']['posts_per_page'])) {
                                         $q->set('posts_per_page', $element['options']['posts_per_page']);
                                     }
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
     do_action('themeblvd_pre_get_posts', $q, $this);
 }