• Hi
    I am working on a one page site using smoothscroll, It’s coming along nicely except one huge thing – I’m not sure how I am going to get the posts to display in the right areas

    I am listing the pages like this:

    // define how pages will display
    $args = array(
    	'sort_order' => 'ASC',
    	'sort_column' => 'post_date', //post_title
    	'hierarchical' => 1,
    	'exclude' => '',
    	'child_of' => 0,
    	'parent' => -1,
    	'exclude_tree' => '',
    	'number' => '',
    	'offset' => 0,
    	'post_type' => 'page',
    	'post_status' => 'publish'
    );
    $pages = get_pages($args);
    //start loop
    
    foreach ($pages as $page_data) {
        $content = apply_filters('the_content', $page_data->post_content);
        $title = $page_data->post_title;
        $slug = $page_data->post_name;
    ?>
    <div id='<?php echo "$slug" ?>' class="section">
            <h1 class="page_title"><?php echo "$title" ?></h1>
    			<?php echo "$content" ?>
    </div>
    <?php } ?>

    If I query the posts and put a loop inside of the
    <div id='<?php echo "$slug" ?>' class="section">
    it will just post in every ‘section’

    Is there any kind of if post_category==page_title thing I can do to effectively query posts in this situation? I’m not terribly good at writing php, I usually can figure it out but I’m pretty stuck on this one, I’d appreciate any help.

    here is a link to the development site

    Thank you in advance

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    There’s a couple approaches, what property defines each area may determine the better approach.

    You could modify the query with GROUPBY and ORDERBY parameters. Then code within the loop will detect when the area changes and output whatever HTML is required to delineate each area.

    Or you could do nested loops. The outer loop is for each area. Then a query is made just for posts in that area. The results of the query drive the inner loop. You end up doing a separate query for each area.

Viewing 1 replies (of 1 total)
  • The topic ‘one page site set, but how do I get the posts to display in the right area?’ is closed to new replies.