Grow your CSS skills. Land your dream job.

[Solved] Custom field

  • # August 7, 2009 at 11:42 am

    Hey, i have been hanging around for a while and realy enjoy chris work with this site :) .

    Now, im trying to learn some more advanced stuff in wordpress.

    And right now im trying to list products on a page, i have almost no experience with php so ive run into some problems.

    What i want to do is list products on a page, each product in a div with a thumb, a description and a price. all typed in from a custom field.

    Ive managed to get the description and the price printed on each product, but the thumb isnt showing.

    The page works fine, the products all list fine exept the image.

    I would apprichiate if someone could point me in the right direction here.

    Code:
    < ?php
    $products = get_post_meta($post->ID, “product”, false);

    if ($products[0]==””) { ?>

    < ?php } else { ?>

    Products

    < ?php foreach($products as $product) {

    $temp = explode("&", "$product");
    $descrip = $temp[0];
    $price = $temp[1];
    $img = $temp[2];

    echo '

    ‘.$descrip.’   ‘.$price.’   

    ‘; } ?>

    < ?php } ?>

    In the custom field i type in information like this: (img url)&(description)&(the price).

    I run wordpress 2.8 and php5 on one.com

    //Azezer

    # August 7, 2009 at 1:29 pm

    What is being outputted? Do you have a link?

    # August 7, 2009 at 3:08 pm

    Here is the link:

    http://azezer.se/blog2/

    //Azezer

    # August 7, 2009 at 3:11 pm

    Ah, it’s working fine, it’s just that you missed an equal sign after "src":

    echo ‘<div class="grid">’.$descrip.’&nbsp;&nbsp;&nbsp;’.$price.’&nbsp;&nbsp;&nbsp;<img src="’.$img.’" /></div>'; } ?>

    # August 7, 2009 at 3:17 pm

    Haha, thank u =)

    sometimes it feels like i earn a gold medal ;)

    So, now i can continue the learning process =)

    // Azezer

    # August 7, 2009 at 3:21 pm

    This is now resolved, cant find the button for it.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".