WordPress.org

Ready to get started?Download WordPress

Forums

Custom field with multiple value? (3 posts)

  1. yhosi
    Member
    Posted 2 years ago #

    I want multiple values for one custom field.
    The value should change if a vistor clicks on a link on my blog.

    For example:

    I have a custom field named "picture".
    This custom field should contain 2 different values.
    One Value should be "www.example.com/picture1.jpg" the other value should be "www.example.com/picture2.jpg".

    If someone clicks on a link "Picture 1" or "Picture 2" the value of the custom field should change to the specified value.

    Please help! I am begging you please, please help!

  2. Cudazi
    Member
    Posted 2 years ago #

    You can add multiple custom fields using the same key on your post or page.

    While I don't know your specific theme setup, you can loop through each via this simplified script below...

    <?php
    $pictures = get_post_meta($post->ID, 'picture', false);
    foreach($pictures as $picture) {
     echo $picture; // do something
    }
    ?>

    Note the third "false" parameter above from:
    http://codex.wordpress.org/Function_Reference/get_post_meta#Parameters

  3. yhosi_2
    Member
    Posted 2 years ago #

    But how do I make this, if somebody clicks on a link and the value changes?

    Thank you very much for your reply.

    (Sorry, I lost my password that's why this is another account)

Topic Closed

This topic has been closed to new replies.

About this Topic