Shortcode

This topic contains 22 replies, has 3 voices, and was last updated by  Peter Wesche 7 years, 8 months ago.

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #23591

    I am looking for a shortcode.

    On a Single Event Site i want load in Content a list like this:
    All Dates from this Event on this Venue …

    I cant figured out what it looks like.

    Christoph Steinlechner
    #23595

    Hi Christoph,

    There’s no such shortcode, although it is fairly simply to implement such a shortcode. Alternatively you can edit the templates (this would be preferably if you want every event to list the dates, rather than having to remember to add the shortcode).

    The default templates do actually list all the (future) dates of the current event. Is there a reason it needs to be a shortcode?

    Stephen Harris
    #23609

    the reason is that i want the dates on other place.

    Christoph Steinlechner
    #23612

    and if i use template in my themefolder the css are not loading correctly.

    so please make such easy shortcode 🙂

    Christoph Steinlechner
    #23624

    Christoph,

    I can reply later today with a code snippet, but if you prefer, just send me the theme via e-mail with details on where you want the list displayed, I can customize the template for you.

    By default the dates appear just above the event content. Where do you want the dates to appear instead?

    Stephen Harris
    #23626

    i read all about template editing but my development is not so good and my developer is out of order …i am searching for new one.

    so my suggestion is just a shortcode for list the eventdates like %this%.

    so the shortcode i can place anywhere on single-event page where i want to show the customer the actual dates.

    Christoph Steinlechner
    #23630

    Hi Christoph,

    If you add the following snippet to a ultility plug-in then you can use the [my_event_dates] shortcode to list all (future) dates of the current event. You can other attributes as required

    add_shortcode( 'my_event_dates', 'my_event_dates' );
    function my_event_dates( $atts, $content = null ){
            $event_id = get_the_ID();
            if ( 'event' !== get_post_type( $event_id ) ) {
                    return;
            }
    
            return do_shortcode( "[eo_events event_series={$event_id} event_start_after=now]" );    
    }
    

    Alternatively, if you’re adding the shortcode manually, you can always use [eo_events] shortcode direclty and use the event_series attribute to specify the event (when editing an event, you’ll see the ID of the event in the URL: e.g. /wp-admin/post.php?post=XXX

    Stephen Harris
    #23636

    ahh great. can i add this to my theme function php or where u mean?

    i need a few more attributes like this
    [eo_events event_tags= or event_title= ] %venue%[/eo_events]

    then i can list any event anywhere what i tagged or named ..…

    Christoph Steinlechner
    #23639

    ah sorry one i forget i want to add also custom_field{} tag …
    after this soluten i think it works … i want show u the finish what i did … its crazy 🙂

    Christoph Steinlechner
    #23642

    sorry for my additional answers

    look … if this:

    [eo_events event_custom_field{Custom-Field-Name}]
    %event_title%
    in %event_venue%
    am %start{j. F o}%
    [/eo_events]

    would work … … i think this is final what i need 🙂

    (only first line –> [eo_events event_custom_field{Custom-Field-Name}] is not working)

    Christoph Steinlechner
    #23643

    Hi Christoph,

    What exactly would the custom field tag do? Filter by events with that custom field? Is that irrespective of the value? Could the event tags be re-purposed for that?

    Stephen Harris
    #23648

    The Custom_Field Tag says what events are shown in the list.

    i make a workaround for my client. the only thing he have to do is change these tags from event and i can show everything what i want on a page.

    hmm u see it here.
    http://www.demo.medios-seminare.de

    dont know if u understand my logic?

    if i finish this i would show u the details.

    a short explain:
    http://b9icqu9.myraidbox.de/kurse/Massagetherapeut/
    this is a normal post, where i load events. BUT i only want load
    events with the Tag “Massagetherapeut”
    Other solution would be: Show only events with page-title “Massagetherapeut” or show only events with page-title=this (that would be the master solution 🙂 )

    i am very close for finish what i have in my mind 🙂 i am sure it will works 🙂

    Christoph Steinlechner
    #23651

    You can list events by title with this snippet:

    add_filter( 'posts_where', function( $where, $query ) {
            global $wpdb;
            $title = $query->get('title');
            if ( $title ) {
                    $where .= $wpdb->prepare( " AND post_title=%s", $title );
            }
            return $where;
    }, 10, 2 );
    

    (you may want to replace ‘title’ with something less generic). It would allow you to list all events with title “Event title” as follows:

    [eo_events title="Event title"]
    

    If you didn’t want to have to specify the post title each time, you could create a shortcode as I’ve demonstrated in an earlier reply to obtain the title of the current post and insert that title as the attribute value.

    Stephen Harris
    #23652

    hey stephen … if i add ur snippet to my function php … same as i did it with other snippet i get white page … could you check please.

    but ur second solution that i have not to type the title would be great.
    can u give me the snippet for that please?

    Christoph Steinlechner
    #23653

    That snippet works fine for me. What version of PHP are you using?

    Here’s a snippe for creating a short code where you don’t need to specify the title:

    add_shortcode( 'events_by_current_title', 'my_events_by_title' );
    function my_events_by_title( $atts, $content = null ){
            $event_id = get_the_ID();
            if ( 'event' !== get_post_type( $event_id ) ) {
                    return;
            }
    
            $title = get_the_title(); 
    
            return do_shortcode( "[eo_events title={$title} event_start_after=now]" );    
    }
    

    and then use the shortcode events_by_current_title (you will need the over snippet too though)

    Stephen Harris
Viewing 15 posts - 1 through 15 (of 23 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.