Shortcode
This topic contains 22 replies, has 3 voices, and was last updated by Peter Wesche 8 years, 7 months ago.
-
AuthorPosts
-
August 1, 2016 at 3:27 pm #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
August 1, 2016 at 5:57 pm #23595Hi 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
August 2, 2016 at 5:09 pm #23609the reason is that i want the dates on other place.
Christoph Steinlechner
August 2, 2016 at 6:34 pm #23612and if i use template in my themefolder the css are not loading correctly.
so please make such easy shortcode 🙂
Christoph Steinlechner
August 4, 2016 at 8:58 am #23624Christoph,
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
August 4, 2016 at 9:08 am #23626i 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
August 4, 2016 at 10:49 pm #23630Hi 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 requiredadd_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 theevent_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
August 5, 2016 at 6:11 am #23636ahh 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
August 5, 2016 at 3:23 pm #23639ah 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
August 5, 2016 at 4:48 pm #23642sorry 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
August 5, 2016 at 10:09 pm #23643Hi 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
August 6, 2016 at 8:45 am #23648The 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.dedont 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
August 6, 2016 at 9:01 pm #23651You 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
August 8, 2016 at 6:28 am #23652hey 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
August 8, 2016 at 8:59 am #23653That 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
-
AuthorPosts