Custom Fields
Support General $echo = false does not work for rwmb_the_value, getting url of advanced image fi

  • Creator
  • #32394
    Resolved Lanzelot Moll

    i am trying to do something like this in a loop:

    (I removed the < >, so it is not displayed as an image here)

    $query = new WP_Query( array( 'post_type' => 'bild' ) );
    in the Loop:
      $bild = rwmb_the_value($field_id = "url_", $echo =false);
      echo 'img src="', $bild, '" /';'

    I have two questions. First of all $echo = false does not work for me.
    Everytime the Url is output into the HTML instead of just being returned to the variable.
    How can I fix this?

    Apart from the echo issue the first version is working, but i would prefer to use rwmb_the_value/rwmb_meta to get the url of a image that is selected by the advanced image field. So I my client can choose an image directly instead of having to search for the url. So to say:

    $image = rwmb_the_value(or rmwb_meta?)( $field_id = 'field_id', array( 'size' => 'original' ), $echo = false)
    echo 'img src="', $bild['url'], '" /';

    I found something with rmwb_meta in the single image documentation but it did not work.
    Can you provide me with the correct syntax please? And tell me how to resolve the echo issue?

    Special thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
  • #32401
    Lanzelot Moll

    Also i don't understand this:

    echo '<p>', rwmb_the_value($field_id = "textarea_"), '</p>';

    why does this output the text of the textarea twice? Again here, $echo = false does not work

    Lanzelot Moll

    So in the end I tried to use the shortcodes instead and the problem vanished. Everything is just displayed once. The documentation says that the shortcode and the the_value function do the exact same thing? In my case they definitely did not!

    do_shortcode( ' [rwmb_meta id="bild" attribute="url" size="large"] '

    by looking for shortcodes, I also came across the solution for my url problem

    Long Nguyen


    You just need to run the helper function rwmb_the_value() to print out the field value without using echo. Please refer to this topic

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.