Support

Account

Home Forums Backend Issues (wp-admin) Including ACF Custom Fields in single.php Template

Unread

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.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.