• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Custom PHP file

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Custom PHP file

This topic is: resolved

Tagged: php

  • This topic has 2 replies, 2 voices, and was last updated 9 years, 7 months ago by manavecplan.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • April 28, 2016 at 11:40 pm #184660
    manavecplan
    Member

    hey,

    I'd like to dump all of my custom functional PHP into a separate PHP file rather than use the default functions.php

    This is what I'm using to link a custom.css file:

    //ADMIN: Adding custom CSS file
    function custom_load_custom_style_sheet() {
    	wp_enqueue_style( 'custom-stylesheet', CHILD_URL . '/custom.css', array(), PARENT_THEME_VERSION );
    }
    add_action( 'wp_enqueue_scripts', 'custom_load_custom_style_sheet' );

    However, similar code used for PHP doesn't seem to work:

    //ADMIN: Adding custom PHP file
    function custom_load_custom_php_sheet() {
    	wp_enqueue_style( 'custom-phpsheet', CHILD_URL . '/custom-functions.php', array(), PARENT_THEME_VERSION );
    }
    add_action( 'wp_enqueue_scripts', 'custom_load_custom_php_sheet' );

    Also, when I use the following code, I get a parse error:

    //ADMIN: Add custom PHP file
    include_once( get_stylesheet_directory() . '/custom-functions.php' );
    

    How do I work around this?

    http://avinashdsouza.me/
    April 29, 2016 at 6:48 am #184678
    Victor Font
    Moderator

    wp_enqueue_style is for style sheets only. wp_enqueue_scripts is for JavaScript files only. The way to call custom php files is with:

    require_once( get_stylesheet_directory() . '/custom-functions.php' );

    Make sure the file is placed in the child theme directory.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    May 2, 2016 at 11:04 pm #184870
    manavecplan
    Member

    Perfect! Thanks a ton Victor....that worked like a charm! 🙂

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Custom PHP file’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble