All-in-One Event Calendar
[resolved] Making Event details searchable and adding Custom Fields to the (7 posts)

  1. hypeon
    Posted 2 years ago #

    I'm in a bit of a pickle, I need the Event details to be searchable throughout my WordPress site. So far it's only possible to look up the title text, tags and categories, which is fine but I'm trying to make other variables searchable as well e.g. the Venue name or the Contact name. As the above didn't seem to be an option, I started looking into Custom Fields since they were searchable. But I would also have to display them in a custom template but the get_post_meta function doesn't seem to work.

    Not sure what I should do now, or even if this is possible but essentially I would like the ability to add custom fields and make both them and the Event Details searchable. Thanks!


  2. Richard
    Posted 2 years ago #

    Hi hypeon,

    Custom fields should work if you insert this:
    <?php the_meta(); ?>
    into your event-single.php file

    I hope this helps!

  3. hypeon
    Posted 2 years ago #

    Thanks Richard, tried it out. the_meta works but it shows it as an ul.

    What I want is the value only. I tried:

    echo get_post_custom_values('value');


    echo get_post_meta($post->ID, 'value', true);

    But neither seem to work. I'm no PHP wiz so I'm not sure what I'm doing wrong just trawling through forums trying to find the solution. Your help is appreciated.

  4. Richard
    Posted 2 years ago #

    Hi hypeon,

    Please try this:

    if ( $keys = get_post_custom_keys() ) {
                     foreach ( (array) $keys as $key ) {
                             $keyt = trim($key);
                             if ( is_protected_meta( $keyt, 'post' ) )
                             $values = array_map('trim', get_post_custom_values($key));
                             $value = implode($values,', ');
                             echo apply_filters('the_meta_key', "$key: $value\n", $key, $value);
                     } ?>
  5. hypeon
    Posted 2 years ago #

    Thanks for that. Played around with it but I kept getting:

    PHP Parse error: syntax error, unexpected $end in ...\event-single.php on line 84

    I'm not sure if I was being clear, basically I've added a custom field key to the post.

    It's called 'MHRA Representative' and the value is MR X.

    I need the right query to produce the value i.e. MR X, but not the key name / field name itself. That's what I'm having trouble with at the moment.

  6. hypeon
    Posted 2 years ago #

    BOOM. Not to worry I've finally found the answer. here.

    <?php echo get_post_meta( $event->post_id, 'key value', true); ?>


  7. Richard
    Posted 2 years ago #

    You're Welcome!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • All-in-One Event Calendar
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic