Basically I am using Advanced Custom Fields and have an ajax tabbing system that works with the ACF.

The current set up is below:

<ul class="css-tabs">
      <li><a class="current" href="/wp-content/themes/blue-and-grey/uni-general.php">General</a></li>
      <li><a href="/wp-content/themes/blue-and-grey/uni-courses.htm">Courses</a></li>
      <li><a href="/wp-content/themes/blue-and-grey/uni-inthearea.htm">In the area</a></li>
      <li><a href="/wp-content/themes/blue-and-grey/uni-sportsandfacilities.htm">Sports & facilities</a></li>

At the moment, I am loading external php documents through AJAX, only problem is, the php is not loading as when echo'ing that field, it cannot be found as it is held elsewhere.

How can I use the custom fields to display what's in that page template, that is held elsewhere?

I current am using:

<?php echo the_field('current_students'); ?>

To display the field, but where it's an external PHP document, it doesn't work.

1 Answer 1


the_field() takes an optional second parameter of $post_id. If you know the post you want, presumably you can use that to grab the data you need.

  • I could try that, however it's a template that will be used across multiple pages so I cannot just put a single $post_id in, there will be tens of pages underneath this template. Jul 10, 2012 at 19:30
  • @OwenO'Neill - So, you gotta pass the second parameter in your Ajax page load...
    – brasofilo
    Jul 10, 2012 at 22:15
  • managed to do it with div's instead of loading external documents. Thank you very much though! Jul 12, 2012 at 23:55
  • 1
    Owen how did you do it? I am currently trying to do the same without any luck. It would be great if you could let me know how you did it. Thanks :)
    – Towfiq
    May 20, 2013 at 6:01

Your Answer

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

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