WordPress.org

Ready to get started?Download WordPress

Forums

Quick Functions.php Question (3 posts)

  1. johnb21
    Member
    Posted 1 year ago #

    I am curious about adding new actions/filters to functions.php. Should I separate each action and filter inside its own <?php ?> tag? Or should it all be compiled into one and separated just by the semi-colon?

    If more clarity is needed, please post it here so I can try and clarify a bit better.

  2. fonglh
    Member
    Posted 1 year ago #

    It's fine to put them all together.

  3. Will D. White
    Member
    Posted 1 year ago #

    The functions.php is a PHP file. That means that by default you can start the file with <?php and put as much as you want - and then close the file with ?>

    The only time you close the PHP tag is when you want to post HTML to the website (or run another language, I suppose). Like in your theme files like page.php or header.php where you would stop using PHP for a while and use HTML instead:

    EG: <?php if(is_page()){ ?>Some cool html here<?php } ?>

    In the example, it says "if this is a page" (using PHP) and then switches back to HTML for a while. Then when you're done posting HTML code you close it back up with another php setting <?php } ?>

    I hope that helps clear up how PHP works within the theme structure for ya!

Topic Closed

This topic has been closed to new replies.

About this Topic