Anyone know how to use custom fields in wordpress? Need some help please !!!

Discussion in 'PHP' started by johno123, Jan 19, 2009.

  1. #1
    Anyone know how to use custom fields in wordpress?


    I need some custom fields setup in wordpress. But, i have no idea on how to accomplish this.


    That would give the author two options for the author to be able to choose one of, when he/she edits a thier post.

    example...

    field title

    Item Status:

    authors choices

    Sold
    Not Sold


    Displaying only one of those chosen options at the bottom of each post.



    I want these options to display as a dropdown box for the author.

    And to display only the one option chosen by the author, for the the person reading the post.


    And how do you get the field to display? Is there some code that needs to be added to the single.php file?



    hope that makes sense...


    Anyone able to help?
     
    johno123, Jan 19, 2009 IP
  2. qualityfirst

    qualityfirst Peon

    Messages:
    147
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    0
    #2
    <?php if( get_post_meta($post->ID, "INSERTCUSTOMFIELDNAMEHERE", true) ): ?>
    				    <?php echo get_post_meta($post->ID, "INSERTCUSTFIELDNAMEHERE", true); ?>
    				<?php else: ?>
    PHP:
    Try that. Incorporate it into your theme files.
     
    qualityfirst, Jan 19, 2009 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
  4. johno123

    johno123 Well-Known Member

    Messages:
    1,492
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    130
    #4
    i dont know how to use that bit of code. Or even how to create the custom fields.


    really struggling with this feature..
     
    johno123, Jan 19, 2009 IP
  5. johno123

    johno123 Well-Known Member

    Messages:
    1,492
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    130
    #5
    Ok, so i installed custom fields template plugin and now i need to know what code i need to add to single.php to make the new fields show..


    i hope this works
     
    johno123, Jan 19, 2009 IP
  6. johno123

    johno123 Well-Known Member

    Messages:
    1,492
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    130
    #6
    i tried using <?php the_meta(); ?> to make the fields show that worked.

    but it also shows other custom fields, that is dont want there. Ratings and views and counter. I did not manually create them. But i do use them on my post pages. i try and delete them and they just reapear



    Any ideas
     
    johno123, Jan 19, 2009 IP
  7. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #7
    Use
    get_post_meta($post_id, $key, $single);
    PHP:
     
    Danltn, Jan 20, 2009 IP