Events Shortcode – Tags included?

Home Forums Calendar Products Events Calendar PRO Events Shortcode – Tags included?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1253692
    Uwe Matern
    Participant

    Good Morning from Hamburg,

    we use all the PRO Versions of the calendar and tickets.
    Quick question: We want to build up a few dedicated pages on our website around certain important (SEO) keywords.

    Thus we intend to use the events-shortcode of the PRO version in order to present events tagged with those keywords. So, is there an option to specify also “tag” as an attribute of the events-shortcode?

    Best regards
    Uwe

    #1254252
    Hunter
    Moderator

    Hello, Uwe!

    Thank you for reaching out and welcome back 🙂

    According to the PRO Widget Shortcodes Knowledgebase article, it is possible to accomplish what you’ve described with essentially no caveats. I set up a test event titled “Uwe” and created a new tag also named “Uwe”. I located the tag term_id for the “Uwe” tag which is 20. With that information, the following shortcode succesfully displayed events tagged with “Uwe” exactly as you’ve requested!

    [tribe_events_list tags=”#20″]

    If you’re unaware of the easiest process to identify the tag term_id, visit Events > Tags in your WordPress dashboard. Hover over the Delete button for the tag you want to acquire the term_id for. Once you’ve done that, if you look at the very bottom of your browser window, look for a link and there will be a section in that link which says, “tag_id=some-number“. The number immediately following the = symbol is your term_id. I’ve shared a screenshot showing which if you look at the very bottom, you’ll see “tag_id=20“.

    Let me know how things work out and please review all documentation relative to shortcodes to learn even more shortcodes available to use around your site. Cheers!

    #1254292
    Uwe Matern
    Participant

    Good Morning Hunter,

    thanks for your answer. Your proposal in general works fine (I identified the tag-id) and are able to select the wished events with this shortcode.

    But, because we customized heavily, would use the list-view, created by using the: [tribe_events category=”malerei-zeichnung” view=”list” tribe-bar=”false”] – shortcode. The only problem seems to be, that I cannot use the attribute “tags” here?

    Is there an option to add a filter or something that the shortcode could be enhanced to understand this attribute?

    Best regards
    Uwe

    #1254828
    Hunter
    Moderator

    Hi Uwe,

    Welcome back 🙂

    Unfortunately, tags are not currently a supported attribute when using the [tribe_events] shortcode. I’ll provide some code below to help get started. By itself it doesn’t do anything, at the very minimum the modify() method would need to be completed – but it shows how you can wrap the existing shortcode and graft on support for extra attributes:

    class Tribe_Events_Shortcode_Enhancement {
    protected $atts;

    public function __construct() {
    add_action( 'init', array( $this, 'reregister' ) );
    }

    public function reregister() {
    if ( class_exists( 'Tribe__Events__Pro__Main' ) ) {
    add_shortcode( 'tribe_events_list', array( $this, 'wrapper' ) );
    }
    }

    public function wrapper( $atts ) {
    $this->atts = $atts;
    add_action( 'tribe_events_pro_tribe_events_shortcode_prepare', array( $this, 'modify' ) );
    Tribe__Events__Pro__Main::instance()->shortcodes->tribe_events( $atts );
    }

    public function modify( $shortcode ) {
    // Make calls to $shortcode->update_query() from here in order to adapt the query to match
    // the attributes contained in $this->atts: this effectively lets us add support for
    // new attributes not supported by the default implementation
    }
    }

    new Tribe_Events_Shortcode_Enhancement;

    You would make a copy of that code and in the modify method (the one where all the lines are commented out) you’d basically check if anything is specified then modify the query from there, a little like this:

    if ( empty( $this->atts[ 'tags' ] ) ) {
    return;
    }

    $this->update_query( array(
    'tag__in' => $this->atts[ 'tags' ]
    ) );

    That’s a simplification – you’re probably going to want to do some sanity checks, etc. I wish I could provide more at this time, but unfortunately you’ll have to manage things from here on out. I’ve created a feature report for the developers to review for them to include tags as an attribute in the [tribe_events] shortcode and incorporating it into a feature release. I also recommend visiting our UserVoice Feature Ideas and submitting the request there.

    Good luck and have a great afternoon! Cheers 🙂

    #1254938
    Uwe Matern
    Participant

    Dear Hunter,

    thanks so much for your support. Will test it in a bit later stage. Looking forward to the release when this feature is in.

    You can close the ticket for now.

    Best regards

    Uwe

    P.S. You have a lot of examples of the events calendar implementation globally on your site. What are the criterias to be presented there?

    #1255584
    Hunter
    Moderator

    Welcome back, Uwe!

    I truly appreciate your understanding our limitations in this particular situation, but logic dictates the WP tags should be an available attribute when using the [tribe_events] shortcode. So I’m glad we have it “in the books” and hopefully can get it included sooner rather than later.

    Feel free to visit our Contact page including a link to the site(s) you’d like considered and we’d be more than happy to review them when time allows. Our criteria isn’t set in stone; it’s basically a matter of does it look good? Does it offer anything slightly different from other installs running our plugins? And so forth.

    I’ll go ahead and close this thread out but please feel free to create a new one should the need arise. Have a great upcoming weekend and thanks again! Cheers 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Events Shortcode – Tags included?’ is closed to new replies.