Support

Account

Forum Replies Created

  • Ah nevermind! I see my error now. I made a couple of PHP typos.

    I switched the exclamation points in that one line of code to be this:

    if (isset($subtext) || '' !== trim($subtext))

    It now works. Sorry to waste your time.

    Thanks,
    Brian

  • Hi John,

    Thanks. I appreciate the basic info, though perhaps I have understated my experience level. I’m more an intermediate-level coder with respect to both WordPress and PHP; I understand the basics of both, but still have to look up a lot of things like filters and actions or PHP functions and precise parameters as I more often than not need a refresher.

    So, I definitely do know which template I’m using for the page in question already. I can tell in the page editor, and it’s a template I wrote the PHP file for myself. Other fields and custom fields are working fine, including not only the built-in WYSIWYG editor but 3 other ACF fields. Only the ACF WYSIWYG field is not displaying anything.

    I’ve also tried echoing the problematic ACF field both inside and out of the loop, to no avail.

    Maybe a code snippet would be helpful. Here’s my template PHP file’s contents (page-feature.php). The $subtext variable (get_field(“additional_subtext”)) is the problematic field; the other three fields all work fine ($heading and $button_text are ACF Text fields, $btnLink is an ACF Link field).

    <?php
    /**
     * Elegant Simplicity Theme: Feature Page Template
     *
     * This template is...
     *
     * Template Name: Feature Page
     *
     * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
     *
     * @package Elegant_Simplicity
     * @since 5.2.0
     */
    
            get_header();
    
            $heading = get_field("heading");
            $btnText = get_field("button_text");
            $btnLink = get_field("featured_link");
            $subtext = get_field("additional_subtext");
    ?>
            <h1 class="cover-heading"><?php echo $heading; ?></h1>
    <?php   while (have_posts())
              {
              the_post();
              get_template_part('template-parts/content-featurepost', 'page');
              }
    ?>      <p class="lead"><a href="<?php echo $btnLink; ?>" class="btn btn-lg btn-outline-secondary"><?php echo $btnText; ?></a></p>
    <?php   if (!isset($subtext) || '' === trim($subtext))
              {
              echo $subtext;
              }
    
            get_footer();
    ?>

    Thanks!

Viewing 2 posts - 1 through 2 (of 2 total)