Hooks and Filters and Shortcodes

Community Forums Forums General Discussion Hooks and Filters and Shortcodes

This topic is: resolved

This topic contains 4 replies, has 4 voices, and was last updated by  PittsburghChris 1 year, 2 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #30932

    faith
    Participant
    Post count: 24

    Hi, I installed the Genesis Visual Hook Guide plugin and I understand the Markup option, but I still don’t understand how to use Hooks and Filters and Shortcodes. The pages in the Tutorials give long lists, but I don’t know in what context and how to use them. It’s just not clicking for me. What’s the difference between Action Hooks and Filter Hooks. Are there examples of how to use all of these? All I see in the tutorials to understand filters is a Filter Reference – a list of filters built into the Genesis Framework, but do I use them if I don’t even understand how to apply them?

    #31029

    braddalton
    Participant
    Post count: 8892

    The hooks enable you to display content in those locations and style your content using CSS rules in that specific location.

    You can add custom widget area’s, display images or any other HTML and even use conditional tags to display content only on specific pages in that location.

    Example:
    [php]
    function display_welcome_text() {
    echo "Howdy Folks!";
    }
    add_action( ‘genesis_after_content’, ‘display_welcome_text’ );
    [/php]

    This code. once added to your child themes functions.php file will output the welcome text, Howdy Folks in the genesis_after_content hook location.

    Here’s a few more code snippets you can test to learn how hooks and filters work in Genesis http://www.briangardner.com/code/

    http://gregrickaby.com/2011/02/genesis-code-snippets.html


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #31030

    Gary Jones
    Moderator
    Post count: 686

    Have you read the guide on the WordPress Codex?

    Basically, an action hook says “Take action at this point in the code” – could be to add some new content in, or make so other change for later in the code.

    A filter however is for filtering something – usually a string, so “Take this ‘Leave a comment’ string, and replace it with something else”.

    Shortcodes are what they describe themselves as – codes that are a shorthand of creating content. You’d usually use them within your post and page content, but Genesis also uses them within post meta and footer content too.


    Changes in Genesis 2.1 – the ultimate guide to every single change in Genesis Framework 2.1 and 2.1.1 (all 88 of them!) | @GaryJ

    #31049

    faith
    Participant
    Post count: 24

    Thank you so much for explaining in more detail, the example, and the resources too! (I’ve printed this out.)

    #40668

    PittsburghChris
    Participant
    Post count: 2

    Yeah thanks so much guys. I was struggling with the context of this, too.  Gary, I’ll look through the Codex for action hooks as you mention. I had not done so before and appreciate the extra pointer.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.