Receive Image URL

Support MB Term Meta Receive Image URLResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #34384
    SG5SG5
    Participant

    Dear customer support,

    I have added custom fields to the product tags. In particular a single image. I would like to receive that image URL inside a functions.php method. However, I can not receive the URL from the field. How can I access the image URL?

    add_action('wp_head', 'receive_image_url'); function receive_image_url(){ $image = rwmb_meta( 'single_image_qn1rks1dhnn', array( 'size' => 'thumbnail' ) ); //doesn't get anything $test = rwmb_the_value( 'single_image_qn1rks1dhnn', array( 'size' => 'thumbnail' ) ); //doesn't get anything $key_1_values = get_post_meta( get_the_ID(), 'single_image_qn1rks1dhnn', true ); //receive an array

    echo "URL: " . $image['url'] . "TEST: " . $key_1_values; //echo "<style>.term-" . get_queried_object_id() . " .page-title-default { background-image: url(/wp-content/uploads/aktuelles2-header-background.jpg);} </style>"; }

    Thanks

    #34418
    Long NguyenLong Nguyen
    Moderator

    Hi,

    To get the term meta value, please follow this documentation https://docs.metabox.io/extensions/mb-term-meta/#getting-field-value

    For example:

    $image = rwmb_meta( 'single_image_qn1rks1dhnn', ['object_type' => 'term', 'size' => 'thumbnail'], get_queried_object_id() );
    echo '<img src='. $image['url'] .' />';
    #34446
    SG5SG5
    Participant

    Hi,
    Great it works - thanks!

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