wordpressadvanced-custom-fieldsgenesis

Wy am I getting fatal error message with this code


I am using the genesis sample child theme and I getting the following error message: Fatal error: Cannot redeclare landing_do_content() (previously declared in XXX. I have reviewed all files and the function is not declared anywhere else.

`// Display content of flexible content layouts add_action( 'genesis_entry_content', 'landing_acf_content' );

function landing_acf_content() { if( have_rows('landing_page_content') ) { ?>

    // Hero with text and button layout
        if( get_row_layout() == 'hero_with_text_and_button' ) { ?>

            <div class="landing-hero" style="background: url(<?php echo get_sub_field('hero_image'); ?>); background-size: cover;">
                <div class="hero-content light dark">
                    <div class="wrap">
                        <h1 class="hero-title"><?php echo get_sub_field('headline'); ?></h1>
                        <p><?php echo get_sub_field('text'); ?></p>
                        <a class="button" href="<?php echo get_sub_field('url'); ?>"><?php echo get_sub_field('button'); ?></a>
                    </div>
                </div>
            </div>

        <?php } 

        // Headline with WYSIWYG
        else if( get_row_layout() == 'headline_with_wysiwyg' ) { ?>

            <div class="heading-text" style="background-color: <?php echo get_sub_field('background_color'); ?>">
                <div class="wrap">
                    <h2 class="plain-title"><?php echo get_sub_field('headline'); ?></h2>
                    <?php echo get_sub_field('content'); ?>
                </div>
            </div>

        <?php }

<?php }

}`


Solution

  • If you are declaring a global function and not one inside a class, make sure to only call the file with this function only once, if you require or include the php file more than once, it will result in redeclaration error.