• Resolved cono02

    (@cono02)


    Hi
    I have added some custom fields using the Field Editor which was easy enough. I have also been able to display a Single Select field adding the following code in the content-single-event-listing.php override file:

    <?php echo "Difficulty Level: "; echo get_post_meta(get_the_ID(),'_difficulty_level',true); ?>

    However I have a Multi-Select Field which holds multiple selected values about a Dog, such as Playful or Friendly. The meta Key is ‘_temperament_of_dog’. Example of the placeholder values: friendly:Friendly |playful : Playful|energentic : Energentic

    When I use the following code, it returns ‘Array‘ on the page rather than the actual values. Code:

    <?php echo "Temperament of dogs: "; echo get_post_meta(get_the_ID(),'_temperament_of_dog',true); ?>

    I found some code online which suggests a for loop is needed. Code:

    $temperament = (array) get_post_meta( $post->ID, '_temperament_of_dog', true ); 
    foreach( $temperament as $temp){ echo $temp['value'];} ?>

    When I use the above code it seems to display the first letter of each selected value. So if Playful and Friendly is chosen, it displays as ‘PF’. Also I put [‘value’] as I wasn’t sure what this would be and was trying differnt things.

    Can someone help and explain how to display a multi-select list of values. I have no experience of PHP and find altering code quite tricky without proper guidance to follow.
    Thanks.

    • This topic was modified 4 years, 9 months ago by cono02.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @cono02

    You are too close to solving there is just one change that will allow you to print the data.

    $temperament = get_post_meta( $post->ID, '_temperament_of_dog', true ); 
    foreach( $temperament as $key => $val){ 
      echo $key; // if you want to print key use this 
      echo $val; // if you want to print value use this
    }

    Thank you

    Thread Starter cono02

    (@cono02)

    Hi Hitesh

    Amazing! That has worked perfectly.

    Thank-you very much for your help.

    Thread Starter cono02

    (@cono02)

    Hi Hitesh

    I have another question about the single event listing page. Is it possible to edit this page with Elementor? I have edited the event listings page using elementor but can’t find a way to do so for a single page. I would like to add a custom image behind the header and some other stylings which would be impossible for me without a page builder.

    Thank-you

    Hi @cono02

    Yes, you can edit page with elementor pro and use dynamic tags to show event fields value at frontend.

    Thank you

    hi,

    We hope your issue has been resolved. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://www.ads-software.com/support/plugin/wp-event-manager/reviews/ about your overall experience with WP Event Manager? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.
    Team Support.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display custom multi-select fields’ is closed to new replies.