Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>
    </ul>

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.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
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. –  Owen O'Neill Jul 10 '12 at 19:30
    
@OwenO'Neill - So, you gotta pass the second parameter in your Ajax page load... –  brasofilo Jul 10 '12 at 22:15
    
managed to do it with div's instead of loading external documents. Thank you very much though! –  Owen O'Neill Jul 12 '12 at 23:55
    
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 '13 at 6:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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