Using custom views while looping through pages
-
Hello
Sorry for my English in advance ??
Im developing single view wp template.
In index.php I have loop that is giving me pages content, titles, thumbs etc.I was usign this tutorial: https://www.themevan.com/build-an-one-page-portfolio-website-with-wordpress/
here is the loop:
<?php query_posts('post_type=page'); if (($locations = get_nav_menu_locations()) && $locations['primary_navi'] ) { $menu = wp_get_nav_menu_object( $locations['primary_navi'] ); $menu_items = wp_get_nav_menu_items($menu->term_id); $pageID = array(); foreach($menu_items as $item) { if($item->object == 'page') $pageID[] = $item->object_id; } query_posts( array( 'post_type' => 'page','post__in' => $pageID, 'posts_per_page' => count($pageID), 'orderby' => 'post__in' ) ); } while(have_posts() ) : the_post(); ?> <div id="<?php echo $post->post_name;?>" class="page-contener"> <header class="entry-header"> <h1 class="entry-title"><?php the_title(); ?></h1> </header> <div class='page-img'> <?php if (has_post_thumbnail()): ?> <img class="" src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>&h=235&w=960&zc=1" alt="<?php the_title(); ?>"/> <?php else: ?> <?php endif; ?> </div> <div class="entry-content page-content"> <?php the_content(); ?> </div> </div> <?php endwhile; ?> <?php wp_reset_query();?>
Now I would like to use custom view templates in that loop like contact page template, fullwidth, 1 column, portfolio etc.
How can I access something like page template type and use that template?
Ideal solution would be to detect page template in loop and then use that template, defined in standard “my-custom-template.php” with data provided by the loop.I hope this clear enough :).
- The topic ‘Using custom views while looping through pages’ is closed to new replies.