I am using a custom query to get pages. I need them all displayed on the front page for a one page WordPress theme. For the most part, I have the theme working and things are fine. I have this problem with the code where it doesn't recognize page templates and other custom stuff like shortcodes. For the life of me, I can't figure out why. Some shortcodes work and others do not. I had to make a query that checks to see if the page has a page template asssigned and then run the template part for content-page. Here is my code for my loop
$page_query = new WP_Query(array(
'post_status' => 'publish',
'post_type' => 'page',
'order' => 'ASC',
'orderby' => 'menu_order',
'posts_per_page' => '-1',
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
));
if ( $page_query->have_posts() ) : while ( $page_query->have_posts() ) : $page_query->the_post(); ?>
<?php $template = get_post_meta( get_the_ID(), '_wp_page_template', TRUE ); ?>
<?php if( $template && $post->post_content != '' ) { ?>
<li id="page_<?php echo str_replace(' ','_',strtolower( get_the_title())); ?>">
<?php get_template_part( 'content', 'page' ); ?>
</li>
<?php }
endwhile;
endif;
?>
I have to load all my content by a shortcode. If I try to set a custom page template to a page then when I load that page, it will be blank. The page ignores the content of the custom template. The loop does notice that a page template was assigned though.
what I would like to know is if there is a better way to load all pages into the front page and make WordPress recognize all content like it does for a regular page. I have been trying for months to come up with another way to no avail.
Thank you for your help.