• Resolved 61pixels

    (@61pixels)


    Using Dynamic Render Templates for the first time. In my file for the flexible field, I have <?php echo ($is_preview) ? ‘is-preview’ : ”; ?> inside my wrapper div class=””. It all works great, but on the front-end when viewing source I’m getting <br /> <b>Warning</b>: Undefined variable $is_preview in ….

    I tried searching support on here, and didn’t see any reference to this. I understand the value should be false since we’re not on the backend and nothing should be echoed. Just curious how to remove the output warning in the HTML.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter 61pixels

    (@61pixels)

    Figured this out. I was still using my old “flexible-loop.php” template part which called the fields the normal way in a big if statement calling the individual template parts.

    Once I noticed that, I changed the code to your has_flexible, is_flexible and the errors were gone.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    I’m glad to hear that you managed to fix your issue.

    As a side note, I would recommend to enable the WP_DEBUG & WP_DEBUG_LOG constants, and disable WP_DEBUG_DISPLAY in your wp-config.php file.

    This will will write PHP errors in the /wp-content/debug.log file instead of displaying them on-screen, as display errors might break some functions like server redirection if there is a warning/error. Additionaly you’re sure that there is no warning hidden in HTML like here.

    You can read more about how to setup a favorable environment for WP & ACF development in our guide here.

    Have a nice day!

    Regards.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘$is_preview() throwing undefined warning on front-end’ is closed to new replies.