• 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

How to modify Genesis core function?

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 › How to modify Genesis core function?

This topic is: not resolved

Tagged: core, function, genesis

  • This topic has 2 replies, 2 voices, and was last updated 10 years, 8 months ago by maurisrx.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • September 20, 2014 at 7:10 am #125129
    maurisrx
    Member

    I am trying to modify a Genesis framework core function. I want to remove strip_shortcodes() from the function get_the_content_limit(). Here is my code:

    if ( wp_get_theme( 'genesis' ) ) {
    // replace get_the_content_limit() with the custom one
    remove_filter( 'the_content_limit', 'get_the_content_limit' );
    add_filter( 'the_content_limit', 'custom_get_the_content_limit' );
    
    // copied from genesis/lib/functions/formatting.php:57
    function custom_get_the_content_limit( $max_characters, $more_link_text = '(more...)', $stripteaser = false ) {
    
        $content = get_the_content( '', $stripteaser );
    
        //* Strip tags and keep shortcodes so the content truncation count is done correctly
        $content = strip_tags( $content, apply_filters( 'get_the_content_limit_allowedtags', '<script>,<style>' ) );
    
        //* Remove inline styles / scripts
        $content = trim( preg_replace( '#<(s(cript|tyle)).*?</\1>#si', '', $content ) );
    
        //* Truncate $content to $max_char
        $content = genesis_truncate_phrase( $content, $max_characters );
    
        //* More link?
        if ( $more_link_text ) {
            $link   = apply_filters( 'get_the_content_more_link', sprintf( '… <a href="%s" class="more-link">%s</a>', get_permalink(), $more_link_text ), $more_link_text );
            $output = sprintf( '<p>%s %s</p>', $content, $link );
        } else {
            $output = sprintf( '<p>%s</p>', $content );
            $link = '';
        }
    
        return apply_filters( 'get_the_content_limit', $output, $content, $link, $max_characters );
    
    }
    }

    Usually it works when I use this technique to modify WordPress core function. Am I doing something wrong?

    Thank you,
    Yudhistira

    September 20, 2014 at 10:03 am #125144
    Brad Dalton
    Participant

    The problem is most non Genesis users hack the WordPress core or their parent theme core which is not best practice when both have built in filter hooks.

    Genesis have a lot, here's some http://my.studiopress.com/snippets/

    WordPress have nearly 2000


    Tutorials for StudioPress Themes.

    September 20, 2014 at 9:51 pm #125190
    maurisrx
    Member

    Hi braddalton, thank you for the answer.

    If I modify Genesis core, it works perfectly. But it doesn't work using filter like my code above. remove_filter() function seems not working. I want to include it in a plugin so hacking Genesis core is not an option.

  • 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