Add other details to an evenement

This topic contains 6 replies, has 2 voices, and was last updated by  Stephen Harris 9 years, 5 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #18878

    Hello!

    Is there a way to add other details to an evenement ?

    An example here : http://www.owly.fr/evenements/evenement/mika/

    I’d like to add a “facebook page link” field for example.

    Thanks!

    Alex

    Alexandre Janvier
    #18904

    Yes, one way of doing this is to make use of custom fields. These are no different from the custom fields you get on posts, so I’ll refer to you the codex for details: https://codex.wordpress.org/Custom_Fields

    If you want that included with the event details, you should copy the template event-organiser/templates/event-meta-single-event.php into your theme and edit to include:

    <?php 
        printf( 
            '<a href="%s">Facebook page</a>', 
            esc_url( get_post_meta( get_the_ID, 'facebook_url', true ) )
        );
    ?>
    

    where I have assumed facebook_url is the custom field key. You may want to wrap it inside a conditional to check that the value for facebook_url is not empty (i.e. a url hasn’t been provided), otherwise the link will point nowhere.

    Stephen Harris
    #19069

    Hello Stephen,

    Thank you for your help and sorry to respond to your lately.

    I tried what you said and mentionned regarding “Custom fields” but unfortunately it seems to do not work fine :-S .

    Here is what i have for my example :

    printf('Facebook: Visiter', esc_url( get_post_meta( get_the_ID, 'facebook_url', true ) ) ); printf('<br/>'); 
    

    And here is what I did in my wordpress admin page of the event (sorry it’s in french) :

    enter image description here

    And nothing is done, it does not work. Can you help me on it ?

    Thank you,

    Regards,

    Alex

    Alexandre Janvier
    #19072

    Please see this page on how to use printf: http://php.net/manual/en/function.printf.php

    It will replace placeholders (e.g. %s), with the values you provide – in your case you are not using any placeholders, just the literal text Facebook: Visiter

    Stephen Harris
    #19073

    It was not the code provided in my message, it has been automatically modified by the forum 🙁

    printf('Facebook: Visiter', esc_url( get_post_meta( get_the_ID, 'facebook_url', true ) ) );
    

    I hope this time it will work ^^

    Alexandre Janvier
    #19074

    Ok, hum…. still the same…

    You can find the real code posted here :

    http://owly.fr/autre/exemple1.txt

    Alexandre Janvier
    #19075

    I see, and I see that your previous code snippets have not rendered correctly.

    You are using get_the_ID, it should be get_the_ID(), i.e.

    printf( '<strong>Facebook:</strong> <a href="%s">Visiter</a>', esc_url( get_post_meta( get_the_ID(), 'facebook_url', true ) ) );
    

    (The forum uses markdown, by the way)

    Stephen Harris
Viewing 7 posts - 1 through 7 (of 7 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.