为什么我会收到此代码的致命错误消息

问题描述

我正在使用创世纪示例子主题,并且收到以下错误消息:致命错误:无法重新声明landing_do_content()(以前在XXX中声明。我已经查看了所有文件,并且未在其他任何地方声明该函数

`//显示灵活内容布局的内容 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 }

}`

解决方法

如果要声明一个全局函数而不是一个类中的一个,请确保仅使用此函数调用该文件一次,如果您多次要求或包含php文件,则将导致重新声明错误。 / p>