• Resolved syafiqsyazre

    (@syafiqsyazre)


    Hi,

    What is the best practice to include the custom function in woocommerce.

    Cause i noticed got two different functions.php which are in wp-includes/functions.php and wp-content/themes/twentytwenty/functions.php.

    If I put that custom function inside the theme folder, when updating theme the function will disappears. So i’ve include the function inside wp-content folder. But I’m not sure if it’s a best practice or not.

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you do not want this you can easily create a plugin yourself

    1) Navigate to the WordPress plugins folder
    2) Create a new folder for your plugin (my-functions-plugin)
    3) Create the main PHP file for your plugin (my-functions-plugin.php)
    4) Setup your plugin’s information

    <?php
    /**
     * Plugin Name: My Functions Plugin
     * Plugin URI: https://www.mywebsite.com/my-functions-plugin
     * Description: My Functions Plugin.
     * Version: 1.0
     * Author: Your Name
     * Author URI: https://www.mywebsite.com
     */
    
    //add_action( ... );
    

    5) Save and activate the plugin

    From now on you can place everything you would put in the functions.php file in your own plugin file

    Regards

    Thread Starter syafiqsyazre

    (@syafiqsyazre)

    Hi,

    That explains everything, thanks!

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom function in functions.php’ is closed to new replies.