• 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

add_action within a 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 › Design Tips and Tricks › add_action within a function

This topic is: resolved

Tagged: actions

  • This topic has 6 replies, 2 voices, and was last updated 11 years, 11 months ago by orbiterred.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • January 12, 2014 at 9:31 pm #84898
    orbiterred
    Member

    Hey Everyone,

    So after a few days I'm feeling like I'm starting to get the hang of things! I can see how Genesis is way easier to deal with than Thesis in the long run, that's for sure.

    Anyways, my question is as follows.

    Can I add an action within a function

    Example:

    add_action ( 'genesis_before_footer', 'sample_action' );

    function sample_action() {
    echo '<div class="mydiv">';
    add_action( 'genesis_before_footer', 'another_action' );
    echo '</div>';
    }

    function another_action() {
    echo '<p>Some Stuff here</p>';
    }

    What I'm actually trying to do is add a few widgetized areas into that div (mydiv) but before registering everything I just tried to get the action working and having no luck.

    Suggestions please!

    Cheers,

    Rob

    January 12, 2014 at 10:38 pm #84908
    Genesis Developer
    Member

    Do not need to call the another action. Just remove this line add_action( ‘genesis_before_footer’, ‘another_action’ ); and put this line echo '<p>Some Stuff here</p>'; there. it should work.


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    January 12, 2014 at 11:02 pm #84911
    orbiterred
    Member

    Sorry, poor example.

    I'm trying to call a widget inside of the function.

    I've registered the widget:

    genesis_register_sidebar( array(
    'id' => 'testimonialwidget1',
    'name' => __( 'Testimonial Widget 1', 'themename' ),
    'description' => __( 'Use this widget area to add and remove testimonials from main page', 'themename' ),
    ) );

    function testimonial_widget_1() {
    genesis_widget_area( 'testimonialwidget1', array(
    'before' => '<div class="testimonialwidget1">',
    'after' => '</div>',
    ));
    }

    add_action ( ‘genesis_before_footer’, ‘sample_action’ );

    function sample_action() {

    echo ‘<div class=”mydiv”>’;

    add_action( ‘genesis_before_footer’, ‘testimonial_widget_1’ );

    echo ‘</div>’;

    }

    Widget area shows up in the wp-admin but is not showing on the site.

    Sorry if this is a bit muddy, been up too long.

    January 12, 2014 at 11:07 pm #84912
    Genesis Developer
    Member

    Remove this

    
    function testimonial_widget_1() {
    genesis_widget_area( ‘testimonialwidget1′, array(
    ‘before’ => ‘<div class=”testimonialwidget1″>’,
    ‘after’ => ‘</div>’,
    ));
    }
    
    add_action ( ‘genesis_before_footer’, ‘sample_action’ );
    
    function sample_action() {
    
    echo ‘<div class=”mydiv”>’;
    
    add_action( ‘genesis_before_footer’, ‘testimonial_widget_1’ );
    
    echo ‘</div>’;
    
    }

    And then try this

    add_action ( 'genesis_before_footer', 'testimonial_widget_1');
    
    function testimonial_widget_1() {
    echo '<div class="mydiv">';
    genesis_widget_area( 'testimonialwidget1′, array(
    'before' => '<div class="testimonialwidget1">',
    'after' => '</div>',
    ));
    echo '</div>';
    
    }

    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    January 12, 2014 at 11:51 pm #84918
    orbiterred
    Member

    how about if I want to add 3 different widgetized areas? into mydiv

    January 13, 2014 at 12:04 am #84919
    Genesis Developer
    Member

    then you can do this

    add_action ( 'genesis_before_footer', 'my_widgets');
    
    function my_widgets() {
    echo '<div class="mydiv">';
    genesis_widget_area( 'testimonialwidget1', array(
    'before' => '<div class="testimonialwidget1">',
    'after' => '</div>',
    ));
    genesis_widget_area( 'widget-2', array(
    'before' => '<div class="widget-2">',
    'after' => '</div>',
    ));
    genesis_widget_area( 'widget-3', array(
    'before' => '<div class="widget-3">',
    'after' => '</div>',
    ));
    echo '</div>';
    
    }

    You will register widget 2 & widget 3


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    January 13, 2014 at 12:15 am #84922
    orbiterred
    Member

    Seems so obvious once I see it 🙂

    Thanks!!!

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Design Tips and Tricks’ 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