WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] custom field help (3 posts)

  1. hcvitto
    Member
    Posted 5 years ago #

    i'm trying to use custom field to retrieve info about img to display in my pages (not in posts).
    i have this template

    <?php get_header(); ?>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div id="content" id="post-<?php the_ID(); ?>">

    <?php $id = $post->ID; ?>

    <?php $img = get_post_meta($id, 'immagine'); ?>

    <img src="path-to-image-folder/<?php echo $img; ?>.jpg" />

    <?php $content = get_the_content(); ?>

    <?php echo $content; ?>
    </div>
    <?php endwhile; endif; ?>

    <?php get_footer(); ?>

    but what i get is just ( header and footer show fine )

    <div id="content" id="post-144">
    <img src="path-to-image-folder/.jpg" />
    </div>

    i put content both in the page and in the custom field 'immagine' but nothing works and the content doesn't even show.

    if i use the_content() insted of get_the_content(); it's even worse!
    all i got is the broken img and this html code!!

    <p class="attachment"><img src="path-to-image-folder/prk-300x51.jpg" width="300" height="51" class="attachment-medium" alt="" /></p>

    i used the EasyPermGals and then i deactivate it (i read somewhere that some plugin use to cache stuff in wp db)

    any help? thanks
    vitto

  2. hcvitto
    Member
    Posted 5 years ago #

    sorry if i insist..any idea?

  3. hcvitto
    Member
    Posted 5 years ago #

    resolved!
    get_post_meta gave me 'array' as result until i added the false paramter..

Topic Closed

This topic has been closed to new replies.

About this Topic