• 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

Using functions file instead of Simple Hooks

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 › Using functions file instead of Simple Hooks

This topic is: resolved
  • This topic has 4 replies, 2 voices, and was last updated 10 years ago by Brad Dalton.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • May 26, 2013 at 6:52 pm #42739
    emasai
    Participant

    I have been using Simple Hooks for a while but would really like to know how to write these into the functions file. I have read Nick the Greeks Genesis Explained series, which still remains all Greek to me as it is obviously over my level of programming comprehension. I just read, comprehended and implemented a great tutorial on creating and placing a widget via functions - http://wpdaily.co/genesis-hooks/

    This is the type of tutorial or explanation I'm looking for. Does anyone know of one or can explain how to do this in a simple fashion?

    Thanks


    Need Website Customization or a Responsive CSS fix? Contact Me
    Lynne emasai.com

    May 26, 2013 at 11:39 pm #42760
    Brad Dalton
    Participant

    There are 2 differences between pasting PHP code into the Simple Hooks field and using the same code in a custom function in your child themes functions.php file.

    1. Firstly, all PHP in simple hooks needs to be wrapped in opening and closing PHP tags

    2. Secondly, PHP in simple hooks doesn't include any of the genesis_hooks in the code because the field already outputs your PHP using that hook.

    Example: If you want to display a slider on the home page using Simple Hooks, you would paste this code into one of the genesis_hook locations. Most likely, the genesis_header hook.

    You could do exactly the same thing using a custom function in your child themes functions.php file and this is the code you would use.

    You can clearly see both code snippets include the tag for the slider however the difference between the 2 code snippets is this:

    The second code snippet includes the genesis_header hook in an add_action which hooks the slider into the header hook position and isn't wrapped in PHP tags as the tags are already included in the functions.php file.

    Its also includes a function using a unique name which describes what the code does. This must be different to the names of all other functions in Genesis and your child theme.

    Learn more:

    http://designsbynickthegeek.com/tutorials/conditional-page-content
    http://devzone.zend.com/4/php-101-part-1-down-the-rabbit-hole/


    Tutorials for StudioPress Themes & WooCommerce.

    May 27, 2013 at 10:12 am #42808
    emasai
    Participant

    Thank you so much for your clear and informative reply. I am now starting to "get it" - yeah! I have also bookmarked your site and code snippets.

    Thanks again.


    Need Website Customization or a Responsive CSS fix? Contact Me
    Lynne emasai.com

    May 27, 2013 at 2:40 pm #42828
    emasai
    Participant

    One question, what is the reason for adding

    "&& function_exists('easing_slider')"

    Thanks


    Need Website Customization or a Responsive CSS fix? Contact Me
    Lynne emasai.com

    May 27, 2013 at 9:35 pm #42861
    Brad Dalton
    Participant

    If the Easing slider plugin is installed, then execute the code and display it in the hook location.


    Tutorials for StudioPress Themes & WooCommerce.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 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