I'm trying to get the url of an image from a MetaBox (plugin) filed on an archive-page.

<?php  
    if ( rwmb_meta( 'field-id' ) ) {

        // Get images   
        $img_srcset_large = rwmb_meta( 'field-id', array( 'size' => 'image-size', 'limit' => 1  ) ); 


        echo $img_srcset_large['url'] 
?>

Unfortunately there is nothing displayed. Can you give me a hint how this code can work on archive-templates? Best

  • Your code is incomplete. Could you post more of it? – Krzysiek Dróżdż Aug 10 at 9:29
$images = rwmb_meta( 'field-id', array( 'size' => 'image-size', 'limit' => 1  ) );
$image = reset( $images );

echo $image['url'];

reference

  • Could you elaborate a little bit and explain why this is an answer? – Krzysiek Dróżdż Aug 10 at 9:24
  • are you sure that field-id is the actual id of your meta-box element ? it looks more like taken from an example. You've to match the id used in the rwmb initialization with: array( 'name' => 'Image Upload', 'id' => 'field_id', 'type' => 'image' – Andrea Somovigo Aug 10 at 10:42
  • Yes of cause, I just used a standard name to show you that. It still not doing anything... – Luke Aug 10 at 12:28

I just found out there need to be special term-id, so like this

$value = rwmb_meta( 'beschreibung_kategorie', array( 'object_type' => 'term' ), $term_id );
echo $value;

But anyway it is still not working.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.