Home Grid Style! Is That Possible?
Topics related to Realistic theme goes here.

TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Home Grid Style! Is That Possible?

linkPost by TahMiD » Wed Jan 03, 2018 8:07 pm

Here Is The PS version of What I wanna do. But In this image, the grid card was from the related post card system. But I wanna keep current list style but a grid form, with two post side by side. (with post excerpt, and view article... button)
2018-01-04_1-32-04.jpg
2018-01-04_1-32-04.jpg (372.76 KiB) Viewed 736 times
User avatar
Asmi Khalil

Site Admin Rank
Posts: 781
Joined: Fri Jun 26, 2015 7:13 am
Display Name: Asmi Khalil
Location: Tunisia

Re: Home Grid Style! Is That Possible?

linkPost by admin » Wed Jan 31, 2018 3:15 pm

Hi again,

Sorry for the late reply!
By the way, I didn't forget about you. I just was extremely busy working on RedWaves update. Now, I will be able to help you creating expandable footer widgets using jQuery. I will update you within a day or two.

Regarding this topic, here is how to do it;
First, we need to keep track of current post in the loop number, to distinguish between first post and other posts. So we need to add a global variable before the loop, initiate it to 1 and then remove it after the loop. So in index.php, archive.php and search.php add this code right after <?php /* Start the Loop */ ?>:
<?php global $realistic_loop;
$realistic_loop['loop'] = 1; ?>
<div class="mdl-grid">
Then add this code right after <?php endwhile; ?>;
</div>
<?php unset( $realistic_loop['loop'] ); ?>
Now, inside /template-parts/content-default.php and /template-parts/content-style1.php replace this line;
<article id="post-<?php the_ID(); ?>" <?php post_class('post-box mdl-card mdl-shadow--2dp mdl-grid mdl-cell mdl-cell--12-col'); ?>>
By this code;
<?php global $realistic_loop;

if ( isset( $realistic_loop['loop'] ) && $realistic_loop['loop'] == 1 ) { ?>

	<article id="post-<?php the_ID(); ?>" <?php post_class('post-box mdl-card mdl-shadow--2dp mdl-grid mdl-cell mdl-cell--12-col'); ?>>

<?php } else { ?>

	<article id="post-<?php the_ID(); ?>" <?php post_class('post-box mdl-card mdl-shadow--2dp mdl-grid mdl-cell mdl-cell--6-col-desktop mdl-cell--4-col-tablet mdl-cell--4-col-phone'); ?>>

<?php }

if ( isset( $realistic_loop['loop'] ) ) {
	// Increment the loop
	$realistic_loop['loop']++;
} ?>
Import this to your child theme if you are using one.
I think there is a world market for maybe five computers. - IBM chairman Thomas Watson, 1943

Who is online

Users browsing this forum: No registered users and 1 guest

It is currently Fri Aug 23, 2019 8:14 pm