Forums

Custom Field Template
return number insted of filepath (3 posts)

  1. bm13kk
    Member
    Posted 1 year ago #

    template:

    [preview]
    type = file
    [preview background]
    type = file

    i upload two images in post. And metadata is numbers, not filepaths:
    var_dump ( the_meta());
    result:
    preview: 65
    preview background: 66

    http://wordpress.org/extend/plugins/custom-field-template/

  2. proximity2008
    Member
    Posted 1 year ago #

  3. bathory
    Member
    Posted 1 year ago #

    Since the link doesn't totally explain what you need to do in this case - you need to set the attachment_id to the name of your custom field and then use the code as it's written on that linked page.

    eg.

    <?php $featured_image = get_custom_field('Featured Image') ?>
    
    <?php $attachment_id = $featured_image; // attachment ID
    
    $image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array ?> 
    
    <img src="<?php echo $image_attributes[0] //inserts the image?>" width="450" height="250" >

    [Please post code snippets between backticks or use the code button.]

    :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic