Thanks for prompt reply. I have indeed looked into Related Records, though to actually retrieve data from related record. In this specific case I am retrieving all values from one table, but it fails for the field “Country”, when it is changed to be Foreign Key (linking field).
But if I can make the related records work, it would help me enormously.
Table 1: SuppliersVenues, PK field Venue ID, FK field Country
Table 2: Countries, PK field Country, I want to output field Slug from table Countries
I have virtual field connected to Table 1 and can successfully retrieve values from it (except the FK field).
I used your example with Events and Locations, but in my case I am fetching related record only one level deep, so it is simpler:
[apr_populate field="Country" relatedTo="Countries"]
[airfield name="Country|Slug"]
But when I try it, it outputs:
[airfield name=”Country|Slug”]
I also use ?fresh just in case.
Am I missing something?
I also tried following PHP code:
<?php
$currentPost = get_post();
$venue = $currentPost ->AirpressCollection[0];
$linked_field = "Country";
$linked_table = "Countries";
$venue->populateRelatedField($linked_field, $linked_table);
echo $venue[0]["Country"][0]["Slug"];
?>
And it fails: the page is not displayed at all and a few lines of error text are shown.
However, I use a plugin called Insert PHP Code Snippet to insert PHP and it worked OK for simple code like:
<?php
$currentPost = get_post();
$venue = $currentPost ->AirpressCollection[0];
echo $venue["Name"];
echo "<br />";
?>
(I was not able to use your example with directly using $post variable, so I had to call get_post() to get $post first).
Any advise?
Thanks!