WordPress.org

Ready to get started?Download WordPress

Forums

Best place for "Front End" PHP (4 posts)

  1. bsandall
    Member
    Posted 1 year ago #

    Sorry if this isn't the correct forum....please feel free to recategorise!!

    -----------------------------

    Good Evening

    Before I get stick into configuring WP I have a few question about where to put some PHP code.

    I've created a custom plugin which carries out some functions. "Front End" PHP code (including some HTML) has been inserted directly into each page via the WP dashboard with the use of a plugin Exec-PHP.

    Using this method of inserting the PHP means that only the visual editor can be used to add content to the page.

    I've copied the "full width" template to create a new template and copied the PHP code. The WP page then uses template, each page will require its own template.

    Is this the best method to add Front End PHP code into a page, or is there a more flexible method?

    Thank for your help.

    Ben

  2. damian.smith
    Member
    Posted 1 year ago #

    Not sure if im on the same page as you on this one, but you could put the code into your themes functions.php and create a function for the code:

    function my_function_name() {
    }

    Then call in the php code using
    <?php my_function_name(); ?>

    Then you just need to update your functions.php to update across the whole site.

  3. bsandall
    Member
    Posted 1 year ago #

    Damian

    Thank you for your reply.

    How would I call the function? would this be in the template file?

    Thanks

    Ben

  4. damian.smith
    Member
    Posted 1 year ago #

    <?php my_function_name(); ?>

    Would be used to call the php function in to any wordpress page you wanted.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags