• Resolved sleeplessindc

    (@sleeplessindc)


    I got the following in debug.log

    PHP Warning: Use of undefined constant ‘init’ – assumed ‘‘init’’ (this will throw an Error in a future version of PHP)

    In my functions.php file, I have

    
    //
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Add RSS news feed
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //
    add_action(‘init’, ‘customRSS’);
    function customRSS(){
    add_feed(‘competitionfeed’, ‘customRSSFunc’);
    }
    function customRSSFunc(){
    get_template_part(‘rss’, ‘competitionfeed’);
    }
    

    What should add_action(‘init’ be replaced with?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Look at the “quotes” around “init”.

    Retype that as

    add_action('init', 'customRSS');

    Do the same with the other lines that use a single quote. They’re using typographic single quotes and not an apostrophe/prime.

    Do you see the difference?

    Thread Starter sleeplessindc

    (@sleeplessindc)

    Thanks Steven. I see the difference. I must have copied and pasted that from somewhere that had displayed them as right and left single quotes. Fortunately, the rest of my functions use the correct apostrophe.

    Thread Starter sleeplessindc

    (@sleeplessindc)

    That fixed the problem. Thanks to your better eyesight.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    ??

    I know only because someone else asked a similar question the other day and it took about 20 back-and-forths before someone popped in and pointed that out.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Codex describes add_action(‘init’ but PHP Debug says this will cause future prob’ is closed to new replies.