Using the grid as a template

Hi there im using the grid as a template, i have added a new “_index.php” in x-child global.

2 problems:
1- sometimes drafts show up in the grid
2- certain posts get duplicated

my code:

<?php // ============================================================================= // VIEWS/GLOBAL/_INDEX.PHP // ----------------------------------------------------------------------------- // Includes the index output. // ============================================================================= $stack = x_get_stack(); if ( is_home() ) : $style = x_get_option( 'x_blog_style' ); $cols = x_get_option( 'x_blog_masonry_columns' ); $condition = is_home() && $style == 'masonry'; elseif ( is_archive() ) : $style = x_get_option( 'x_archive_style' ); $cols = x_get_option( 'x_archive_masonry_columns' ); $condition = is_archive() && $style == 'masonry'; elseif ( is_search() ) : $condition = false; endif; ?> <?php if ( $condition ) { x_get_view( 'global', '_script', 'isotope-index' ); ?>
<div id="x-iso-container" class="x-iso-container x-iso-container-posts cols-<?php echo $cols; ?>">




<?php 

if (have_posts()) {

	
	
	$index_grid   = get_page_by_title(html_entity_decode('Index Grid'), 'OBJECT', 'the_grid');
	$archive_grid = get_page_by_title(html_entity_decode('Archive Grid'), 'OBJECT', 'the_grid');
	$search_grid  = get_page_by_title(html_entity_decode('Search Grid'), 'OBJECT', 'the_grid');
	
	if ($index_grid && (is_home() || is_front_page())) {
		
		The_Grid('Index Grid', true);
		
	} else if ($archive_grid && is_archive()) {
		
		The_Grid('Archive Grid', true);
		
	} else if ($search_grid && is_search()) {
		
		The_Grid('Search Grid', true);
		
	} else {
	
		while (have_posts()) { 
			the_post();
			if ( $stack != 'ethos' ) {
				x_get_view( $stack, 'content', get_post_format() );
			} else {
				x_ethos_entry_cover( 'main-content' );	
			}
		}
		
	}
	
} else {
	
  	x_get_view( 'global', '_content-none' );
	
}

?>
</div>
<?php

} else {

if ( have_posts() ) {
	
	$index_grid   = get_page_by_title(html_entity_decode('Index Grid'), 'OBJECT', 'the_grid');
	$archive_grid = get_page_by_title(html_entity_decode('Archive Grid'), 'OBJECT', 'the_grid');
	$search_grid  = get_page_by_title(html_entity_decode('Search Grid'), 'OBJECT', 'the_grid');
	
	if ($index_grid && (is_home() || is_front_page())) {
		
		The_Grid('Index Grid', true);
		
	} else if ($archive_grid && is_archive()) {
		
		The_Grid('Archive Grid', true);
		
	} else if ($search_grid && is_search()) {
		
		The_Grid('Search Grid', true);
		
	} else {
	
		while (have_posts()) {
			the_post();
			x_get_view( $stack, 'content', get_post_format() );
		}
	}
	
} else {
	
	x_get_view( 'global', '_content-none' );
	
}

}

if (!is_home() && !is_front_page() && !is_archive()) {
pagenavi();
}

?>

http://wordpress-64912-308570.cloudwaysapps.com

Right now “12Some Useful Links for You to Get Started
August 28, 2017Uncategorized” is showing up multiple times

Hey There,

Thanks for writing in! Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself. We do have an in-house custom development team that offer paid services, who may be able to assist. They can be contacted at pinnacle@theme.co if this is of interest to you. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.

Thank you for your understanding.

wow disapointing.

Hello There,

As this is all custom development, regretfully we won’t be able to assist further. Custom development is outside the scope of our support. We’re happy to provide advice and get you started in the right direction, but you would still be responsible for the implementation. I assumed that you already have checked this page: https://theme-one.com/docs/the-grid/#!/grid_as_template

With your code, as I understand, you want to display the following grid in different pages:

  • Index Grid for the blog index
  • Archive grid for all archive pages
  • Search Grid for Search page

Please make sure that Index Grid, Archive Grid and Search Grid has already been created and your condition should only be this:

      <?php if ( is_home() ) : ?>

        <?php The_Grid('Index Grid', true); ?>

      <?php elseif ( is_archive() ) : ?>

        <?php The_Grid('Index Grid', true); ?>

      <?php elseif ( is_search() ) : ?>

        <?php The_Grid('Index Grid', true); ?>

      <?php else : ?>

        <?php while ( have_posts() ) : the_post(); ?>
          <?php if ( $stack != 'ethos' ) : ?>
            <?php x_get_view( $stack, 'content', get_post_format() ); ?>
          <?php else : ?>
            <?php x_ethos_entry_cover( 'main-content' ); ?>
          <?php endif; ?>
        <?php endwhile; ?>
        
      <?php endif; ?>

Hope this helps and thank you very much for your understanding.

1 Like

Yes it works ok, thank you!

Glad to hear it!

About certain posts getting duplicated i finally figured a hack.
My current settings:

in the grid set number of post to -1
Ajax load 6 post at a time.
Wp settings set post ammount to 900

Explanation: If post amount is low “10posts” the grid duplicates the posts in order to show the next 6 posts. A weird bug .

Hey @nathansjcorp,

We are just glad that you have figured it out a way to correct the said issue.
Thanks for letting us know!

Best Regards.