WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display images according to the selected value (2 posts)

  1. bagwis
    Member
    Posted 1 year ago #

    Hello there,
    I am using advanced custom fields plugin and I created a custom field with the name recommendation it is a SELECT field type and it has 5 choices. What I am currently trying to figure out is that how can I display different images according to the selected choice.Say for example I select the first choice then an image will be displayed on my post instead of the word inside the selected choice, then if I again select the second value a another image will be displayed which is only for the second value and so on. It is like a rating that I am trying to do. I tried this code

    <?php $value = get_field('nameofmyselectfield')
    if($value=='Highly Recommened')
    {
    echo <img src="link of my image here"/>
    }
    else if($value=='Recommended')
    {
    echo <img src="link of my image here"/>
    }

    and so on, the same thing with different value for up to 5 times, but my page gave me a white page error.
    I am quite new in php so I have less knowledge on it. Anybody could please help me out?

    Thank you very much

    This is the plugin that I am referring to http://wordpress.org/extend/plugins/advanced-custom-fields/

  2. bagwis
    Member
    Posted 1 year ago #

    By the way, I already resolved it by tweaking my codes.

Topic Closed

This topic has been closed to new replies.

About this Topic