I have a small problem on a wordpress custom post type page, whereby the page content underneath seems to output the last piece of content from one of the custom post types. The code is below.
We wanted to move the page content to below the custom post type and so moved the get_template_part( 'content', 'page' );
function to below the custom post loop. When this function is above the loop, then the page content outputs properly, but above the custom post loop (i.e not as desired).
I know the fix could be fixed, but if so please could you point me in the right direction?
<div id = "feature_boxes_wrap2">
<?php query_posts(array(
'posts_per_page' => 3,
'post_type'=>'feature_box'
)
); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div class = "feature_box2">
<?php echo get_the_post_thumbnail($id, array($image_width,$image_height)); ?>
<h2 class="feature2"><?php the_title();?></h2>
<?php $feature_content = get_the_content(); ?>
<?php echo substr($feature_content, 0, 100); ?>
<br>
<a href = "<?php g5_print_page_link(); ?>">Read more</a>
</div><!-- #feature_box2 -->
<?php endwhile; // end of the loop. ?>
</div><!-- #feature_boxes_wrap2 -->
<?php
the_post();
get_template_part( 'content', 'page' ); ?>
Here, try this:
Add a
wp_reset_query()
before you callthe_post(); [...]
and that should do the trick.For more information: http://codex.wordpress.org/Function_Reference/wp_reset_query