Okay
  Public Ticket #2988851
Sidebar widget - is there a shortcode?
Closed

Comments

  •  2
    publicspace started the conversation

    Hi Zhivko

    I would like to use the sidebar widget, but want to insert it as an element using a hook, so would like to know if there is a Shortcode I can use.  

    (On the site, all the sidebars are customised by section or page using hooks and block elements.  I can insert your calendar block, but the options - Agenda, Grid etc. are not suitable in a sidebar.)  

    A shortcode to use your widget would be ideal.  Alternatively a way to create just a simple list of event titles, which link.

    Hope that is possible.  Thank you.   

  •  877
    Zhivko replied

    Hi,

    Register new shortcode that calls the widget. Like this:

    add_shortcode('stec_list_widget', function () {
        ob_start();     $instance                       = array();
        $instance['title']              = '';
        $instance['calendar_id']        = array();
        $instance['category_id']        = array();
        $instance['status']             = 'upcoming';
        $instance['a_target']           = '_self';
        $instance['click_link']         = 'permalink';
        $instance['max_events_number']  = 5;
        $instance['display_tags']       = true;
        $instance['display_thumbs']     = true;
        $instance['display_location']   = true;
        $instance['display_categories'] = true;
        $instance['display_tickets']    = true;
        $instance['exclude_cancelled']  = true;
        $instance['featured_only']      = false;     the_widget('\Stachethemes\Stec\Stec_Widget_Events_List',  $instance);     return ob_get_clean();
    });

    This code should be placed in your theme or child-theme functions.php file.

    Then you can call the widget via [stec_list_widget] shortcode.


    Stachethemes Developer

  •  2
    publicspace replied

    This is awesome!  Thank you.  Having this List display as a shortcode means it can be displayed in the sidebar along with other things. 

    On large screens, the List means the user can click on individual events listed in the sidebar, and the single event displayed in the main content changes accordingly.  Brilliant.