• 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

Why do you need to add // Start the engine php code

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 › Design Tips and Tricks › Why do you need to add // Start the engine php code

This topic is: resolved
  • This topic has 6 replies, 4 voices, and was last updated 10 years ago by yogidev.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • February 4, 2014 at 4:40 pm #88625
    andym119
    Member

    I'm currently designing a multisite and designing my own child themes.

    Recently, I needed to removed all functions.php files from all genesis child themes and put it in the mu-plugins directory for my multisite architecture reasons.

    However, I was getting an error because of the 'start the engine' code:
    // Start the engine
    require_once( get_template_directory() . '/lib/init.php' );

    So I removed that code and everything perfect and how it should.

    So I was wondering what this code actually does, and if its an important bit of code that I need?

    February 4, 2014 at 9:08 pm #88667
    nutsandbolts
    Member

    The function you removed enqueues the init.php file, which is the main piece of the Genesis framework needed for functionality. It was probably throwing an error because it was moved to a plugin, so it couldn't find the template directory. I would leave that part in functions.php since it's uniform across all the child themes - I'm actually really surprised that the sites are functioning without it.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    February 5, 2014 at 9:53 am #88766
    andym119
    Member

    I just done few tests and your right. I was advised on the wordpress forums to move all my child theme functions to an mu-plugin because I am creating my own child themes that I will be continually making. I would prefer for all my child themes to only contain a styles.css and an images directory as all my child themes will share the exact same functions, so I wanted a single place where I could put all function code that all child themes will share, that way everything is easy to manage, make changes and add functions in the future.

    Is there a way of adding the start engine code to my file in the mu-plugins and be able to use all genesis functionality in it so I don't have to have a functions.php in all child themes.

    Currently I have this code in a file in the mu-plugins directory:

    //* Add HTML5 markup structure
    add_theme_support( 'html5' );

    // Child theme (do not remove)
    define( 'CHILD_THEME_NAME', 'Genesis Sample Theme' );
    define( 'CHILD_THEME_URL', 'http://www.studiopress.com/' );

    // Add Viewport meta tag for mobile browsers
    add_action( 'genesis_meta', 'sample_viewport_meta_tag' );
    function sample_viewport_meta_tag() {
    echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
    }

    // Custom background
    add_theme_support( 'custom-background' );

    // Customize footer
    remove_action( 'genesis_footer', 'genesis_do_footer' );
    add_action( 'genesis_footer', 'sp_custom_footer' );
    function sp_custom_footer() {
    ?>
    <p>test</p>
    <?php
    }

    // Modify the size of the Gravatar in comments
    add_filter( 'genesis_comment_list_args', 'sp_comments_gravatar' );
    function sp_comments_gravatar( $args ) {
    $args['avatar_size'] = 50;
    return $args;
    }

    // comments: Reposition Genesis Comment Form -reply above commments
    add_action( 'genesis_before_comments' , 'wps_post_type_check' );
    function wps_post_type_check () {
    if ( is_single() ) {
    if ( have_comments() ) {
    remove_action( 'genesis_comment_form', 'genesis_do_comment_form' );
    add_action( 'genesis_list_comments', 'genesis_do_comment_form' , 5 );
    }
    }
    }

    //* Modify comments title text in comments
    add_filter( 'genesis_title_comments', 'sp_genesis_title_comments' );
    function sp_genesis_title_comments() {
    $title = '';
    return $title;
    }

    //* Modify the leave a reply (speak your mind) title in comments
    add_filter( 'comment_form_defaults', 'sp_comment_form_defaults' );
    function sp_comment_form_defaults( $defaults ) {
    $defaults['title_reply'] = __( 'All Comments' );
    return $defaults;
    }

    //comments - descending order by default
    if (!function_exists('iweb_reverse_comments')) {
    function iweb_reverse_comments($comments) {
    return array_reverse($comments);
    }
    }
    add_filter ('comments_array', 'iweb_reverse_comments');

    //* Customize the submit button text in comments
    add_filter( 'comment_form_defaults', 'sp_comment_submit_button' );
    function sp_comment_submit_button( $defaults ) {

    $defaults['label_submit'] = __( 'Post', 'custom' );
    return $defaults;
    }

    //* Remove comment form allowed tags
    add_filter( 'comment_form_defaults', 'sp_remove_comment_form_allowed_tags' );
    function sp_remove_comment_form_allowed_tags( $defaults ) {

    $defaults['comment_notes_after'] = '';
    return $defaults;
    }

    // Customize the entry header (requires HTML5 theme support)
    add_filter( 'genesis_post_info', 'post_info_filter' );
    function post_info_filter($post_info) {
    $post_info = '[post_date] [post_comments] [post_categories before="Category: "]';
    return $post_info;
    }

    //* Customize the post meta function
    add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
    function sp_post_meta_filter($post_meta) {
    if ( !is_page() ) {
    $post_meta = '[post_categories before="Category: "] [post_comments] [post_tags before="Tagged: "] [post_edit]';
    return $post_meta;
    }}

    I have no functions.php in any child theme and just have a styles.css in each child theme. Everything seems to work correctly with this setup. However I plan to register a few widget areas, add hooks and remove a couple of genesis admin items. I have just tested these individually and they will not work in the file in mu-plugin but will only work if I have a functions.php in each child theme with the start the engine code at the top.

    Would anyone be able to advise me on the best way to achieve the things I am trying to do.

    February 5, 2014 at 9:57 am #88768
    nutsandbolts
    Member

    I actually really like that approach - I am in the middle of a project where Genesis will be used on a multisite installation, so I see the potential value in maintaining identical functions across all child themes. I have pinged Gary J (who is a Genesis rock star) to see if he has any advice for you.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    February 5, 2014 at 10:46 am #88779
    Gary Jones
    Member

    If you wrap your add_action(), add_filter(), remove_*(), add_theme_support() and basically any other global call (that is not defining a function), into a new function, and then hook that function in to genesis_setup, then by the time that callback is called, all of the Genesis functions will be available. Equally, if Genesis is not the parent or active theme, the plugin won't throw a fatal error, since the hook will never be called, and that won't try and call functions that rely on Genesis code.

    Not documented but this is kind of the idea. Note, I've also fixed up a few small improvements to your code.

    add_action( 'genesis_setup', 'andym_child_setup', 15 );
    function andym_child_setup() {
    	// Add HTML5 markup structure
    	add_theme_support( 'html5' );
    
    	// Child theme (do not remove)
    	define( 'CHILD_THEME_NAME', 'AndyM' );
    	define( 'CHILD_THEME_URL', 'http://www.example.com/' );
    
    	// Add Viewport meta tag for mobile browsers
    	add_theme_support( 'genesis-responsive-viewport' );
    
    	// Custom background
    	add_theme_support( 'custom-background' );
    
    	// Customize footer
    	remove_action( 'genesis_footer', 'genesis_do_footer' );
    	add_action( 'genesis_footer', 'andym_custom_footer' );
    
    	// Modify the size of the Gravatar in comments
    	add_filter( 'genesis_comment_list_args', 'andym_comments_gravatar' );
    
    	// comments: Reposition Genesis Comment Form -reply above commments
    	add_action( 'genesis_before_comments' , 'andym_post_type_check' );
    
    	// Modify comments title text in comments
    	add_filter( 'genesis_title_comments', 'andym_genesis_title_comments' );
    
    	// Modify the leave a reply (speak your mind) title in comments
    	add_filter( 'comment_form_defaults', 'andym_comment_form_defaults' );
    
    	// comments – descending order by default
    	add_filter ('comments_array', 'andym_reverse_comments');
    
    	// Customize the submit button text in comments
    	add_filter( 'comment_form_defaults', 'andym_comment_submit_button' );
    
    	// Remove comment form allowed tags
    	add_filter( 'comment_form_defaults', 'andym_remove_comment_form_allowed_tags' );
    
    	// Customize the entry header (requires HTML5 theme support)
    	add_filter( 'genesis_post_info', 'andym_post_info_filter' );
    
    	// Customize the post meta function
    	add_filter( 'genesis_post_meta', 'andym_post_meta_filter' );
    }
    
    function andym_comment_submit_button( $defaults ) {
    	$defaults['label_submit'] = __( 'Post', 'custom' );
    	return $defaults;
    }
    
    function andym_remove_comment_form_allowed_tags( $defaults ) {
    	$defaults['comment_notes_after'] ='';
    	return $defaults;
    }
    
    function andym_post_info_filter($post_info) {
    	return '[post_date] [post_comments] [post_categories before="Category: "]';
    }
    
    function andym_post_meta_filter($post_meta) {
    	if ( ! is_page() ) {
    		return '[post_categories before="Category: "] [post_comments] [post_tags before="Tagged: "] [post_edit]';
    	}
    }
    
    function andym_custom_footer() {
    	?>
    	<p>test</p>
    	<?php
    }
    
    function andym_comments_gravatar( $args ) {
    	$args['avatar_size'] = 50;
    	return $args;
    }
    
    function andym_post_type_check () {
    	if ( is_single() && have_comments() ) {
    		remove_action( 'genesis_comment_form', 'genesis_do_comment_form' );
    		add_action( 'genesis_list_comments', 'genesis_do_comment_form' , 5 );
    	}
    }
    
    function andym_genesis_title_comments( $text ) {
    	return '';
    }
    
    function andym_comment_form_defaults( $defaults ) {
    	$defaults['title_reply'] = __( 'All Comments', 'andym-child' );
    	return $defaults;
    }
    
    function andym_reverse_comments( $comments ) {
    	return array_reverse( $comments );
    }
    

    WordPress Engineer, and key contributor the Genesis Framework | @GaryJ

    February 6, 2014 at 7:12 am #88928
    andym119
    Member

    Thanks for this this is just what I've been looking for. I'm still learning php so I don't always no what to do for the best and I've been building my php codes from genesis snippets and snippets from some other websites. With this setup, now everything works I can now register widgets, hook them, remove genesis admin items and I now don't have to have a functions.php in each child theme.

    May 1, 2015 at 4:12 am #149703
    yogidev
    Member

    Hi, I just found this post.

    I am fairly new to php, and been searching around for a solution to why my functions stop working when I add the lib/init.php at the top.

    For example, this code stops working:

    // Remove page titles
    //* Remove page title for a specific page (requires HTML5 theme support)
    //* Change '28' to your page id
    add_action( 'get_header', 'child_remove_page_titles' );
    function child_remove_page_titles() {
    if ( is_page( ) ) {
    remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
    }
    } 

    I tried including it within this block but still not working..

    // Start the engine the other way
    
    add_action( 'genesis_setup','genesischild_theme_setup', 15 );
    function genesischild_theme_setup() {
    
    //Add support for HTML5 markup
    add_theme_support( 'html5' );
    //Add viewport metatag
    add_theme_support( 'genesis-responsive-viewport' );
    //Add 3 footer widgets
    add_theme_support( 'genesis-footer-widgets', 4 );
    //Add support for custom background
    add_theme_support( 'custom-background' );
    
    }

    Any help much appreciated!

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Why do you need to add // Start the engine php code’ 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