WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Google Calendar, short code, hooks (3 posts)

  1. blondie53185
    Member
    Posted 3 years ago #

    I am attempting to display a Google Calendar using a hook. I have the calendar displayed properly in a sidebar widget. When I put the short code in a hook, it does not display. Do I need to find the actual html for this to work?

  2. Bill Erickson
    Member
    Posted 3 years ago #

    There's a filter called "do_shortcode" that is used to convert shortcodes into the actual code. It's applied to the post content, but you can apply it to whatever you like.

    The easiest solution would be to create an additional function that applies the shortcode filter to the other one.

    function current_code() {
    echo 'I want to use [shortcodes]';
    }
    
    function shortcode_on_current_code() {
    do_shortcode( current_code() );
    }
    
    add_action('your_hook', 'shortcode_on_current_code');
  3. blondie53185
    Member
    Posted 3 years ago #

    Thank you kindly, sir. I have figured it out, with your help, of course!

Topic Closed

This topic has been closed to new replies.

About this Topic