Advertisement
monzurviserx

ACF helper

Jan 22nd, 2022
1,239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Plugin Name: ACF-Helper
  4.  * Plugin URI: #
  5.  * Description: Custom plugin for ACF.
  6.  * Author: Monzur Alam
  7.  * Version: 1.0.0
  8.  * Text Domain: acf-helper
  9.  * License: GPLv2
  10.  * License URI: https://www.gnu.org/licenses/gpl-2.0.html
  11.  */
  12.  
  13. if (!defined('ABSPATH')) exit; // Exit if accessed directly
  14.  
  15. if (!function_exists('acf_helper_content')) {
  16.     function acf_helper_content($content){
  17.         // now this work on article & page.
  18.         if ( is_singular('post') || is_page() ) {
  19.             ob_start();
  20.             ?>
  21.             <div class="contenitore">
  22.                 <div class="container">
  23.                     <div class="titolo">
  24.                         <?php
  25.                         if (get_field('tipologia')) {
  26.                             echo '<h4>Area di produzione</h4>';
  27.                         } ?>
  28.                     </div>
  29.                     <div id="scheda-dettagli-vino" class="sezione">
  30.                         <?php {
  31.                             echo '<img src="/icone/area-di-produzione.png" />', '<img src="/wp-content/plugins/acf-helper/icone/divisore.png" />';
  32.                             echo esc_html(the_field('tipologia'));
  33.                         } ?>
  34.                     </div>
  35.                 </div>
  36.             </div>
  37.  
  38.             <div class="contenitore">
  39.                 <div class="container">
  40.                     <div class="titolo">
  41.                         <?php
  42.                         if (get_field('tipologia')) {
  43.                             echo '<h4>Tipologia</h4>';
  44.                         } ?>
  45.                     </div>
  46.                     <div id="scheda-dettagli-vino" class="sezione">
  47.                         <?php {
  48.                             echo '<img src="/wp-content/plugins/acf-helper/icone/tipologia.png" />', '<img src="/wp-content/plugins/acf-helper/icone/divisore.png" />';
  49.                             echo esc_html(the_field('tipologia'));
  50.                         } ?>
  51.                     </div>
  52.                 </div>
  53.             </div>
  54.         <?php
  55.             return $content . ob_get_clean();
  56.         }
  57.     }
  58.     add_filter('the_content', 'acf_helper_content');
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement