Site logo

Archived topic

Inserting a grid from The Grid plugin into archive.php

9 replies · Started by Nicolas on July 10, 2021

Viewing posts 1–10 of 10

Hello,

I want to display the archive posts with a grid created with The Grid plugin. I modify the archive.php in my child theme following The Grid authors directions: https://theme-one.com/docs/the-grid/#grid_as_template

The grid is loaded on the archive page but its elements seem to be 0px wide 0px high.

Do you have any advice on how to make it work with Generatepress?

It works if I use the code from my previous theme to create a new archive.php file:

get_header(); ?>	
<meta name="robots" content="noindex,follow">

	<div id="primary" class="content-area">
		<main id="main" class="site-main" role="main">

		<?php 
		
		The_Grid('Posts_archive', true); // where true is for template mode

		if ( have_posts() ) : ?>

			<?php /* Start the Loop */ ?>
			

			<?php while ( have_posts() ) : the_post(); ?>

			<?php endwhile; ?>

		<?php endif; ?>

		</main><!-- #main -->
	</div><!-- #primary -->

<?php get_footer(); ?>

Best,

Nicolas

Hi there,

if you can share a link where i can see the issue, i am happy to take a look to see what that plugin is doing.

Thank you David,

I actually opened the ticket too soon as I was able to make things work.

Best,

Nicolas

Glad to hear that!

Actually I found what seems to cause the error (the grid from The Grid plugin not displaying). It happens when I select "display posts in columns" in the customizer blog settings.

The generate-columns-container element has a 1px height.

It's function conflicts.

So if you are using a custom function to create columns, the GP function is supposed to be turned off.

Glad it's working for you now :)

Thank you Ying, I had a bit of difficulty turning it off for search pages only with conditionals but the code below seems to work:

add_filter( 'generate_blog_columns', 'remove_gppblog_multiple_columns');
function remove_gppblog_multiple_columns( $display ) {
    if ( is_search() )
        $display = false;
    return $display;
}

Try this one :)

add_filter( 'generate_blog_columns','remove_gppblog_multiple_columns' );
function remove_gppblog_multiple_columns( $columns ) {
    if ( is_search() ) {
        return false;
    }

    return $columns;
}

Ah ok, thanks!

You are welcome :)

This archived topic is closed to new replies.