• Resolved gerrycircus

    (@gerrycircus)


    I am creating a post template in my wordpress.

    I need to have:
    1/ a dynamic src inside an image – so I can place “artist-image” as custom field and the path. This works.
    2/ I need to a link underneath that contains a website link
    3/ pretty much the same as number 2

    Here’s my PHP – 2 and 3 aren’t working – but number 1 is. What am I doing wrong? Any ideas?

    <!– I NEED TO POST AN IMAGE FROM THE IMG and THEN TWO SEPERATE LINKS BELOW – 1/ WEBSITE 2/ MYSPACE URL –>

    <div class=”artist-details”>
    <?php
    $artistimageCode = get_post_meta ($post ->ID, ‘artist-image’, true);
    $websiteCode = get_post_meta ($post ->ID, ‘website-address’, true);
    $myspaceCode = get_post_meta ($post ->ID, ‘myspace’, true);
    ?>

    <img src=”<?php echo $artistimageCode; ?>” width=”200″ height=”250″ alt=”music box for life artist” />
    <p>Website: ” target=”_blank”></p>
    <p>Myspace: ” target=”_blank”></p>
    </div>
    <!– artist details close –>

    <!– ARTIST CLOSE –>

Viewing 7 replies - 1 through 7 (of 7 total)
  • From my notes from a thread I can’t find now:

    <?php
    //if custom field is present, formulate and display link from meta value
    $link = get_post_meta($post->ID, 'link_url', true);
    $text = get_post_meta($post->ID, 'link_text', true);
    if ($link){
    echo 'Credit: <a href="'.$link .'">'.$text.'</a>';
    }
    ?>
    Thread Starter gerrycircus

    (@gerrycircus)

    I tried that and it’s still not working. Here’s my latest effort:

    <!– I NEED TO POST AN IMAGE FROM THE IMG and THEN
    TWO SEPERATE LINKS BELOW –

    1/ IMAGE
    2/ WEBSITE
    3/ MYSPACE URL

    THE IMAGE PART IS WORKING AND THE BACKEND OF WORDPRESS REGISTERS THE FACT THAT ARTIST-IMAGE IS THERE
    –>

    <div class=”artist-details”>
    <?php
    $artistimageCode = get_post_meta ($post ->ID, ‘artist-image’, true);
    $websiteCode = get_post_meta ($post ->ID, ‘website-address’, true);
    $myspaceCode = get_post_meta ($post ->ID, ‘myspace’, true);
    ?>

    <img src=”<?php echo $artistimageCode; ?>” width=”200″ height=”250″ alt=”music box for life artist” />
    ” target=”_blank” />
    ” target=”_blank” />
    </div>
    <!– artist details close –>

    <!– ARTIST CLOSE –>

    The forum is not displaying my code properly

    I am essentially placing the php echo where the href path would be. Not sure why it doesnt display here.

    Thread Starter gerrycircus

    (@gerrycircus)

    <!-- I NEED TO POST AN IMAGE FROM THE IMG and THEN
    TWO SEPERATE LINKS BELOW - 
    
    1/ IMAGE
    2/ WEBSITE
    3/ MYSPACE URL 
    
    THE IMAGE PART IS WORKING AND THE BACKEND OF WORDPRESS REGISTERS THE FACT THAT ARTIST-IMAGE IS THERE
    -->
    
    <div class="artist-details">
    	<?php
        $artistimageCode = get_post_meta ($post ->ID, 'artist-image', true);
        $websiteCode = get_post_meta ($post ->ID, 'website-address', true);
        $myspaceCode = get_post_meta ($post ->ID, 'myspace', true);
        ?>
    
        <img src="<?php echo $artistimageCode; ?>" width="200" height="250" alt="music box for life artist" />
        <?php echo $websiteCode; ?>" />
        <?php echo $myspaceCode; ?>" />
    </div>
    <!-- artist details close -->
    
    <!-- ARTIST CLOSE -->

    What’s the value of both custom fields? Show an example.

    Peter

    Thread Starter gerrycircus

    (@gerrycircus)

    Hi Pboosten! Thanks for taking the time out of your day to help me.

    the custom field entries from the back-end are called:

    “artist-image” (this is working)
    “website-address” (this throws an error)
    “myspace” (this throws an error)

    The problem is when I try to ADD a custom field in the backend of WP it says “An unidentified error has occured”.

    But what do you put in as value for those custom fields?

    Peter

    Thread Starter gerrycircus

    (@gerrycircus)

    hey peter

    you got me thinking! i was focussing on the scripting. I updated my version of WP to the latest (just in case) and deleted all my previous entries for custom fields. I re-inputted them and it’s working!

    Thanks for that!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘custom fields get_post_meta question’ is closed to new replies.