This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 2 months, 3 weeks ago.

  • Creator
    Topic
  • #14358

    William Jerome
    Participant

    I am working through getting to know the plugin.

    It is possible to put single image into group? I tried the Group tutorial sample and got no result

    Here is the sample I modified.

    <?php
    $product_colour = rwmb_meta( 'product-colour' ); // ID of the group
    if ( ! empty( $product_colour ) ) {
        echo '<h3>', $product_colour['title'], '</h3>';
        echo '<h3>', $product_colour['image'], '</h3>';
    } ?>

    Also I am getting Undefined index: title error and not sure what that mean?

    Anyone know how to group image and text?

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #14376

    Anh Tran
    Keymaster

    Hi William,

    It’s necessary to check if a group has sub-values for title and image. Please try this code:

    <?php
    $product_colour = rwmb_meta( 'product-colour' ); // ID of the group
    if ( ! empty( $product_colour ) ) {
        if ( ! empty( $product_colour['title'] ) ) {
            echo '<h3>', $product_colour['title'], '</h3>';
        }
        if ( ! empty( $product_colour['image'] ) ) {
            $image = RWMB_Image_Field::file_info( $product_colour['image'], ['size' => 'thumbnail'] );
            echo '<img src="', $image['url'], '">';
        }
    }
    ?>
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.