Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Display child pages in a block grid #255

Closed
JuliaRietveld opened this issue Mar 3, 2015 · 4 comments
Closed

Display child pages in a block grid #255

JuliaRietveld opened this issue Mar 3, 2015 · 4 comments

Comments

@JuliaRietveld
Copy link

Hi,
I would like to display child pages in a four column grid in one of the sections on my front page. Somehow it's not working. I have a feeling that I'm not closing my div's properly. I've tried like a hundred time to close my div's but still no result. All four children pages are displayed in the first column of the four intended. I really appriciate your help on this!
http://pastebin.com/YvYZi38h
Julia

@manwithacat
Copy link
Contributor

Is the goal to have 4 child posts as 3 unit width columns in a row on a large display? In which case, the column should all be defined inside the while block?

  while ( $services_query->have_posts() ) {
    echo '<div class="small-6 large-3 columns">';
    // Render stuff [using Wordpress the_post or similar]
    the_post(); 
    echo '</div>';
  }

Assumes you have only 4 services defined.

@JuliaRietveld
Copy link
Author

James, you are a geniuos! Thank you so much! It was not about where I close the div, but where I open it. Cool!
How about if I want to display only 4 out of many? Thank you!

@manwithacat
Copy link
Contributor

Have a look at "Show x Posts per page" in the "Interacting with WP_Query" documentation.

$args = array(
  'post_type' => 'page',
  'post_parent' => $services_id,
  'posts_per_page' => 4
);
$services_query = new WP_Query( $args );

@JuliaRietveld
Copy link
Author

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants