0

I need to display out the content inside the while loop and by taking the values that i have given in sub-field a group field created in ACF.

  • field group name:career_details
  • field group label:career details
  • field type:group
  • rule:page-template = career-page(my required page)
  • rule:page-template = career-page(my required page)
  • sub field name:job_position,job_location,job_description
  • sub fieled label:job position,job location,job description

theses are the details of field respectevely.

then i have added contents to the all sub fields. when i try to run the following code ,there is no any output. the contents inside the loop is disappeared.

<section class="container" >


<?php if( have_rows('career_details') ): //parent group field
while( have_rows('career_details') ): the_row(); 
?>


<div class="row d-flex justify-content-center">
<div class="col-md-3 no-padd">
<a class="btn btn-success btn-lg green-buttn" href=""><h3 class="h3 
text-buttn text-uppercase"><?php the_sub_field('job_location');  ?> 
</h3></a>
</div>
<div class="col-md-3 no-padd">
<a class="btn btn-danger btn-lg red-buttn" href=""><h3 class="h3 text- 
buttn text-uppercase"><?php the_sub_field('job_position');  ?></h3></a>
</div>
<div class="col-md-6 no-padd d-block">
<div class="click-upload float-right"><a href=""><img class="cv-img" 
src="<?php echo get_template_directory_uri(); ?>/images/cv-upload.jpg" 
alt=""></a></div>

<div class="click-upload float-right"><a href=""><p class="cv- 
text">Click here to <br> upload your cv</p></a></div>
<hr class="hr-dark">
</div>

</div>
<div class="row d-flex justify-content-start">
<h3 class="h3 small-head">Details of this position</h3>
<p class="h5 small-para">
<?php  the_sub_field('job_description') ; ?>
</p>


</div>
<div class="row d-flex justify-content-start bl-btn">
<a class="btn btn-primary blue-btn" href="">
<p class=" text-uppercase name-btn">apply now</p>
</a>
</div>

<?php endwhile; ?>
<?php  endif; ?>


</div>

</section>

Can any one help me to find out

2
  • Are you inside the main Loop of this template - the if(have_posts() ... part? If so, have you set your custom field to be assigned to a specific Post/Page, or are these fields edited in an options page? If they're edited in an options page, you have to add an additional parameter to all of your the_field(), the_sub_field() calls. And if you're not inside the main Loop, you need to include the post ID in your calls to them, so ACF knows which Post/Page to pull them from.
    – WebElaine
    Commented Feb 4, 2020 at 14:17
  • thank you Elaine,as you said ,i was not inside of mail loop.now it is working correctly.you pointed out in the right time
    – Pranavmtn
    Commented Feb 6, 2020 at 8:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.