0

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

1
  • Your code is incomplete. Could you post more of it? Commented Aug 10, 2018 at 9:29

2 Answers 2

0
$images = rwmb_meta( 'field-id', array( 'size' => 'image-size', 'limit' => 1  ) );
$image = reset( $images );

echo $image['url'];

reference

3
  • Could you elaborate a little bit and explain why this is an answer? Commented Aug 10, 2018 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' Commented Aug 10, 2018 at 10:42
  • Yes of cause, I just used a standard name to show you that. It still not doing anything...
    – Luke
    Commented Aug 10, 2018 at 12:28
0

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 agree to our terms of service and acknowledge you have read our privacy policy.

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