1

I'm using get_template_part() function on my file (page-home.php) like page-home.php and it is working fine until I called it 5 times on the same file (page-home.php) but when I called it 6th times like

<?php get_template_part( 'template-parts/content', 'project' ); ?>

data from advanced custom field plugin is not showing, but the data from Custom Post Type UI plugin is showing correctly and if I delete any of the above get_template_part() the data from <?php get_template_part( 'template-parts/content', 'project' ); ?>is showing correctly.

Any type of help is appreciated.

0

Looks like your problem is in the content-project.php file. Whenever using WP_Query() make sure to use wp_reset_postdata(); Additional details can be found here

  • i didn't used wp_reset_postdata(); in any of the above file where i should try putting that i tried just after <?php $loop = new WP_Query( array( 'post_type' => 'project_feature', 'orderby' => 'post_id','order'=>'ASC' ) ); ?> not showing any difrence – user5323957 Aug 9 '16 at 9:37
  • i figured it out just after closing the loop working fine now – user5323957 Aug 9 '16 at 9:41
  • If you have multiple new WP_Query() in a single page make sure to use wp_reset_postdata(); – bagpipper Aug 9 '16 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.