Home › Forums › Front-end Issues › Display ACF without child theme nor functions.php › Reply To: Display ACF without child theme nor functions.php
One developer suggested me to add this code in a new plugin, but doesn’t work.. any suggestions?
<?php
/**
* Plugin Name: ACF-Helper
* Plugin URI: #
* Description: Custom plugin for ACF.
* Author: Monzur Alam
* Version: 1.0.0
* Text Domain: acf-helper
* License: GPLv2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('ABSPATH')) exit; // Exit if accessed directly
if (!function_exists('acf_helper_content')) {
function acf_helper_content( $content ){
if(is_singular('post')){
ob_start();
?>
<div id="scheda-dettagli-vino" class="dettagli-vino">
<table>
<tr>
<td>
<?php
if (get_field('produttore')) {
echo '<img src="/downloads/area-di-produzione.png" />', '<h3 style="display:inline; ">Area di produzione</h3>';
}
?>
</td>
<td>
<?php
if (get_field('produttore')) {
echo esc_html(the_field('produttore'));
}
?>
</td>
</tr>
</table>
</div>
<?php
return $content . ob_get_clean();
}
}
add_filter('the_content', 'acf_helper_content');
}
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.