I’m making a child theme of Listify, and trying to incorporate custom fields (for instance ‘short_address’) in the listing cards. By default these display the featured image and title.
Problem is the file that controls this all is written in an unfamiliar syntax. I can insert text and html into the file, but I’m not sure how to write the custom fields code in the correct syntax for this to work. Below is a snippet of the syntax and code from the file I’m trying to adjust.
For instance, if I add an h4 under the h3, it appears on every listing card. I just can’t figure out how to put the text, i.e. ‘short_address’ inside the h3.
<script id="tmpl-listingCard" type="text/template">
...
<?php
/**
* Insert content at the end of the listing.
*
* @since Unknown
*/
do_action( 'listify_content_job_listing_after' );
?>
<# if ( data.cardDisplay.title ) { #>
<h3 class="job_listing-title">{{{data.title}}}</h3>
<# } #>
...
</script>
This is what I’ve tried. The code below will print the ‘short_address’ for post ID 16859, but I can’t seem to pull in the real post ID # for each post. In this file, {{{data.id}}} represents the post ID, but if I put “{{{data.id}}}” in my php, everything breaks.
<?php // Display short address
$id = 16859;
if( get_field('short_address', $id) ): ?>
<div class="job_listing_acf-address"><?php the_field('short_address', $id); ?></div>
<?php endif; ?>
Doesn’t work:
<?php // Display short address
$id = {{{data.id}}};
if( get_field('short_address', $id) ): ?>
<div class="job_listing_acf-address"><?php the_field('short_address', $id); ?></div>
<?php endif; ?>