Hi. I’m looking to customise the category pages for my site. Currently I have an “_index.php” file in the global folder with the following code:
<?php
// =============================================================================
// VIEWS/GLOBAL/_INDEX.PHP
// -----------------------------------------------------------------------------
// Includes the index output.
// =============================================================================
$stack = x_get_stack();
if ( is_archive() ) :
$style = x_get_option( 'x_archive_style', 'standard' );
$cols = x_get_option( 'x_archive_masonry_columns', '2' );
$condition = is_archive();
if(is_tag()) $my_posts = get_posts(array('tag' => get_query_var('tag')));
else if(is_author()) $my_posts = get_posts(array('author' => get_query_var('author')));
else if(is_date()) $my_posts = get_posts(array('m' => get_query_var('m')));
else $my_posts = get_posts(array('cat' => get_query_var('cat')));
$my_post_ids = array();
foreach($my_posts as $post) {
array_push( $my_post_ids, $post -> ID );
}
elseif ( is_search() ) :
$condition = is_search() && $style == 'masonry';
if(is_tag()) $my_posts = get_posts(array('tag' => get_query_var('tag')));
else if(is_author()) $my_posts = get_posts(array('author' => get_query_var('author')));
else if(is_date()) $my_posts = get_posts(array('m' => get_query_var('m')));
else $my_posts = get_posts(array('cat' => get_query_var('cat')));
$my_post_ids = array();
foreach($my_posts as $post) {
array_push( $my_post_ids, $post -> ID );
}
endif;
?>
<?php if ( $condition ) : ?>
<?php echo do_shortcode('[the_grid name="test"]'); ?>
<?php else : ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php x_get_view( $stack, 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php else : ?>
<?php x_get_view( 'global', '_content-none' ); ?>
<?php endif; ?>
<?php endif; ?>
<?php pagenavi(); ?>
This uses ‘The Grid’ plugin to create a summary of the posts. However, this method displays all posts for all categories. Is there a way of automatically generating posts for only the ones that apply for the category page? If not, do you have any alternative suggestions to using this plugin?