Custom Fields
Support General Get single_image field value outside of loop

  • Creator
  • #21501
    Resolved rubbergumball

    Similar question as at "Possible to retrieve custom field value of specific page outside loop?"

    I would like to add an OG: image file to the header of a specific CPT.

    Current header file code includes the following:

    $postID = get_queried_object_id();  
    $image = get_post_meta( $postID, 'my_img_id', true );
    //also tried these:
        //A  - $image = rwmb_meta( 'my_img_id', '', $postID );
        //B - /*foreach ( $image as $image_id ) {
              $image = RWMB_Image_Field::file_info( $image_id, array( 'size' => 'full' ) ); }*/
    echo "<meta property=\"og:image\" content=\"" . $image[url] . "\" />";

    The data is not populating the variable $image[url] - the field type is simple_image.

    Any thoughts?

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