Home › Forums › Backend Issues (wp-admin) › Including ACF Custom Fields in single.php Template
I am attempting to include ACF meta fields in the single.php template. I have added a section that includes a table with various meta fields. If I copy all the code including/within the TABLE section directly into the post, it will pull the values using the shortcodes. However, in the template file, it just displays the shortcode code as opposed to the actual values. See coding below…
if ( in_category('storm-chase-logs') ) {
echo '<table class="table2" border="1" width="100%" cellspacing="0" cellpadding="0"><colgroup> <col style="width: 50%;" span="1" /> <col style="width: 50%;" span="1" /></colgroup>
<tbody>
<tr>
<td>
<table border="0" width="100%"><colgroup> <col style="width: 50%;" span="1" /> <col style="width: 50%;" span="1" /> </colgroup>
<tbody>
<tr>
<td bgcolor="#e5e5e5"><span style="font-size: 12pt;"> <strong>LOG DATE</strong>:</span></td>
<td bgcolor="#e5e5e5"> <span style="font-size: 12pt;">[xyz-ips snippet="ACF-Log-Date"]</span></td>
</tr>
<tr>
<td> <span style="font-size: 12pt;"><strong>CHASE VEHICLE</strong>:</span></td>
<td> <span style="font-size: 12pt;">[xyz-ips snippet="ACF-Chase-Vehicle"]</span></td>
</tr>
<tr>
<td bgcolor="#e5e5e5"> <span style="font-size: 12pt;"><strong>CHASE PARTNERS</strong>:</span></td>
<td bgcolor="#e5e5e5"> <span style="font-size: 12pt;">[xyz-ips snippet="ACF-Chase-Partners"]</span></td>
</tr>
<tr>
<td> <span style="font-size: 12pt;"><strong>TARGET REGION</strong>:</span></td>
<td> <span style="font-size: 12pt;">[xyz-ips snippet="ACF-Target-Region"]</span></td>
</tr>
<tr>
<td bgcolor="#e5e5e5"> <span style="font-size: 12pt;"><strong>MILES DRIVEN:</strong></span></td>
<td bgcolor="#e5e5e5"> <span style="font-size: 12pt;">BOO</span></td>
</tr>
</tbody>
</table>
</td>
<td>
<table border="0" width="50%">
<tbody>
<tr>
<td align="center" bgcolor="grey"><strong><span style="font-size: 14pt;">SPC OUTLOOK: [xyz-ips snippet="ACF-SPC-Outlook"]</span></strong>
<table border="0" width="100%" bgcolor="#e5e5e5"><colgroup> <col style="width: 33%;" span="1" /> <col style="width: 34%;" span="1" /> <col style="width: 33%;" span="1" /></colgroup>
<tbody>
<tr>
<td align="center"><span style="font-size: 12pt;"><strong>TORNADO</strong></span></td>
<td align="center"><span style="font-size: 12pt;"><strong>HAIL</strong></span></td>
<td align="center"><span style="font-size: 12pt;"><strong>WIND</strong></span></td>
</tr>
<tr>
<td align="center"><span style="font-size: 12pt;">[xyz-ips snippet="ACF-SPC-Tornado"]</span></td>
<td align="center"><span style="font-size: 12pt;">[xyz-ips snippet="ACF-SPC-Hail"]</span></td>
<td align="center"><span style="font-size: 12pt;">[xyz-ips snippet="ACF-SPC-Wind"]</span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" width="100%"><colgroup> <col style="width: 50%;" span="1" /> <col style="width: 50%;" span="1" /></colgroup>
<tbody>
<tr>
<td><span style="font-size: 12pt;"><strong>TORNADOES SEEN:</strong> [xyz-ips snippet="ACF-Tornado"]<strong>
</strong></span></td>
<td><span style="font-size: 12pt;"><strong>FLOODING:</strong> [xyz-ips snippet="ACF-Flooding"]
</span></td>
</tr>
<tr>
<td><span style="font-size: 12pt;"><strong>HAIL ENCOUNTERED:</strong> [xyz-ips snippet="ACF-Hail"]"</span></td>
<td><span style="font-size: 12pt;"><strong>DAMAGE:</strong> [xyz-ips snippet="ACF-Damage"]
</span></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>';
}
// END Chase Log Stats Section
This is a custom template using the single.php file, so I am attempting to make it so that the ACF fields are pulled into the table. Currently, it is just displaying the shortcode text on the front end. Any assistance would be helpful.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.