• Resolved markerdinferno

    (@markerdinferno)


    hi, I’m trying to create a child theme of twentyfourteen with a one-page layout (like braidingfreedom.com). I’m using a different loop to retrieve all the pages but I would like to keep the content-page.php in the get_pages() loop to not break the style.css of the parent theme;

    the loop I’m using now is (inside <div id="content" class="site-content" role="main">):

    <?php
    	$args = array(
    	'sort_order' => 'ASC',
    	'sort_column' => 'menu_order', //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 class='<?php echo "$slug" ?>'>
            <h2><?php echo "$title" ?></h2>
    			<?php echo "$content" ?>
    </div>
    <?php
    }
    ?>

    would like to use get_template_part( ‘content’, ‘page’ ); somewhere but don’t know where exactly.
    Any help is very much appreciated!
    thank you

Viewing 1 replies (of 1 total)
  • Thread Starter markerdinferno

    (@markerdinferno)

    found a solution using WP_Query() instead of get_pages, I managed to include get_template_part( ‘content’, ‘page’ ); so now I’m keeping the original formatting of twentyfourteen.
    the query looks like:

    <?php
            $args=array(
    	'post_type' => 'page',
    	'orderby' => 'menu_order',
    	'order' => 'DESC'
    	);
    // the query
    $the_query = new WP_Query( $args ); ?>
    
    <?php if ( $the_query->have_posts() ) : 
    
    	 while ( $the_query->have_posts() ) : $the_query->the_post();
    		get_template_part( 'content', 'page' );
    	 endwhile; 
    
    	 wp_reset_postdata(); ?>
    
    <?php else : ?>
    	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; ?>

Viewing 1 replies (of 1 total)
  • The topic ‘[Theme: Twentyfourteen] one-page layout’ is closed to new replies.