Support

Home Forums Event Espresso Premium Answers Shortcode with specific length of answer

Answers Shortcode with specific length of answer

Posted: March 21, 2016 at 6:04 am

Viewing 3 reply threads


Taiwan Beast Runners

March 21, 2016 at 6:04 am

Hi,
we use EE3 and lot use price modifier for our sport events. Event use it for one event instead of create more tickets (eg. by distance).
I wish show in participate list answer from certain question with price modifier, I know how (from here https://eventespresso.com/wiki/answers-shortcode/)but in one case wish show only first few letters. 26km [ +NT$4,150.00 ], I want show just first 5 or 4 letter (26km) and hide the additonal price.
example of our event http://www.taiwanbeastrunners.com/events/?ee=20

thank you

eg. answer: 26km
https://eventespresso.com/wiki/answers-shortcode/


Tony

  • Support Staff

March 21, 2016 at 6:33 am

Hi there,

Within the example you linked to the answer is pulled in using:

do_shortcode('[EE_ANSWER q="15" a="'.$id.'"]

If you return that to a variable, you can use substr() to return a section of the string.

Like this:

$full_answer = do_shortcode('[EE_ANSWER q="15" a="'.$id.'"]

$short_answer = substr( $full_answer, 0, 5)

$short_answer will then contain only the first 5 characters of the string.

Does that help?


Taiwan Beast Runners

March 23, 2016 at 5:12 am

Hi Tony,
thank you lot. It took my while of testing, before I realized I add some space before answer and it was showing only them. Now is looking as I want, no best but works.

so far I do reach this style, I would like have it more organized, but it is over my skills.
http://www.taiwanbeastrunners.com/events/?ee=20

Thank you,
Petr


Tony

  • Support Staff

March 23, 2016 at 5:17 am

You’re most welcome, Petr.

I’m glad it worked for you 🙂

Viewing 3 reply threads

The support post ‘Answers Shortcode with specific length of answer’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso