• Cuando creo un plugins para que muestre las siguientes funciones en la página de woocommerce, este no se muestra.

    este es el código en cuestión.

    add_action( 'woocommerce_before_add_to_cart_button', "ACF_product_content", 8 );
     
     if (function_exists('the_field')){
      function ACF_product_content(){
       
       echo '<div class="fdisponibilidad">';
        the_field('fdisponibilidad');
        echo '</div>';
       
      }
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Your plugin is activated, right? Probably, but I’ve missed that one a couple times in the past.

    Ensure the action is actually firing. Place an error_log() call in your callback function (with an appropriate message), then check the log after viewing the page. If there is no log entry afterwards, you need a different action hook. If there is a related log entry, check the page’s source HTML, it may be there, but is hidden by CSS. If it’s not there, the page is probably being cached and you’re seeing stale content. Flush your browser cache and any server side caches.

    Thread Starter alevazke

    (@alevazke)

    El plugins esta activado, la cuestión es que hice que el contenido almacenado mediante campos avanzados se mostrara en la pagina de productos de woocommerce, funciona si esta en el archivo functions.php del theme, pero en cuanto llevo el codigo al plugins, este ya no se muestra en dicha pagina…
    Lo estoy haciendo con el plugins Advance customs Fuelds.

    Moderator bcworkz

    (@bcworkz)

    Your plugin is loading before ACF, so the function_exists('the_field') check fails and your callback is not declared. Move the check to inside the callback and your code will work.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Hook WordPress no muestra con plugins’ is closed to new replies.