• 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

Customize genesis_get_image_id() function on child theme

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 › Customize genesis_get_image_id() function on child theme

This topic is: not resolved

Tagged: child genesis genesis_get_image_id()

  • This topic has 2 replies, 2 voices, and was last updated 11 years, 3 months ago by darkpollo.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • March 16, 2014 at 6:46 pm #95231
    darkpollo
    Member

    Hi,

    I would like to modify the function genesis_get_image_id(): from the image.php file on genesis theme using a child theme but when i tried to add the function into the child theme it returns an error sayiing that it has been already loaded or something like that.

    Do you know how can I modify that function without modifying the original code?

    Thanks

    March 17, 2014 at 1:35 pm #95366
    Brad Dalton
    Participant

    You need to find the filter and use that in a custom function.

    Really depends on what you want to do specifically.

    IMAGE FILTERS

    genesis_get_image_default_args
    Default value: $defaults
    applied to the default arguments added to genesis_get_image function.

    genesis_pre_get_image
    Default value: false, $args, $post
    Allows child theme to short-circuit the genesis_get_image function

    genesis_get_image
    Default value: $output, $args, $id, $html, $url, $src


    Tutorials for StudioPress Themes.

    March 17, 2014 at 1:57 pm #95373
    darkpollo
    Member

    I want to replace the actual genesis_get_image function code and use a new function of my own.

    Normally, when you replace a function using a child theme, the one on the main theme does not load, but here on genesis it loads first the main theme. I think this is a problem that needs to be fixed on the main code.

    From the wordpress guide:
    https://codex.wordpress.org/Child_Themes

    Using functions.php
    Unlike style.css, the functions.php of a child theme does not override its counterpart from the parent. Instead, it is loaded in addition to the parent’s functions.php. (Specifically, it is loaded right before the parent’s file.)

    In that way, the functions.php of a child theme provides a smart, trouble-free method of modifying the functionality of a parent theme. Say that you want to add a PHP function to your theme. The fastest way would be to open its functions.php file and put the function there. But that’s not smart: The next time your theme is updated, your function will disappear. But there is an alternative way which is the smart way: you can create a child theme, add a functions.php file in it, and add your function to that file. The function will do the exact same job from there too, with the advantage that it will not be affected by future updates of the parent theme. Do not copy the full content of functions.php of the parent theme into functions.php in the child theme.

    TIP FOR THEME DEVELOPERS. The fact that a child theme’s functions.php is loaded first means that you can make the user functions of your theme pluggable —that is, replaceable by a child theme— by declaring them conditionally. E.g.:

    if ( ! function_exists( 'theme_special_nav' ) ) {
        function theme_special_nav() {
            //  Do something.
        }
    }

    In that way, a child theme can replace a PHP function of the parent by simply declaring it beforehand.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 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

© 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