WordPress.org

Ready to get started?Download WordPress

Forums

Add custom field to each post (13 posts)

  1. Bareman
    Member
    Posted 5 years ago #

    Hi, I have seen what the custom field can do, but I am bit novice. I need to add a custom piece of text to each post. This is the format:

    Contact: bearman@domainname.com or phone 555 555 5555
    or
    Contact: doggirl@domainname.com or phone 444 444 4444

    How do I do this?
    With custom fields I have to add the number and url each time as I can't leave the value empty.

    Please help

  2. MichaelH
    Member
    Posted 5 years ago #

  3. Bareman
    Member
    Posted 5 years ago #

    Thanks, it looks great but sofar but I cannot get the entries to display in the front end.

    It's what I wanted in the sense that I can define two options:

    - email 1
    - email 2

    and I can just select either one in the backend and post it. This is great because I need to have such an option, where with custom fields one has to re-enter each value everytime, as a key cannot be without the value.

    But as I said I am having a hard time getting the entry to actually display, am I missing something ?

    Yes I am still novice ..

  4. MichaelH
    Member
    Posted 5 years ago #

    You will want to explore Using_Custom_Fields to learn to put code such as in your theme's appropriate template(typically wp-content/themes/your-theme/index.php) to display custom fields.

    Other related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

  5. Hiroaki Miyashita
    Member
    Posted 5 years ago #

    This is an example by use of the custom field template plugin.

    TEMPLATE #0

    [Contact]
    type = text
    size = 35
    
    [Phone]
    type = text
    size = 35

    [cft] Shortcode Format
    FORMAT #0

    Contact: [Contact]
    phone: [Phone]

    In the post, you have to add this:
    [cft format=0]

    That's it:)

  6. MichaelH
    Member
    Posted 5 years ago #

    Very slick. Didn't notice that you could do that with your plugin, Hiroaki Miyashita.

  7. Bareman
    Member
    Posted 5 years ago #

    Holy smoke this works perfect, wow thanks guys. As soon as I added <?php the_meta(); ?> it finally displayed in the front end. I realise now that this plugin is related to the custom fields plugin, and thus you need to add the php code in your index.php

  8. Bareman
    Member
    Posted 5 years ago #

    is there any way I can make the values actual email links WITHOUT the shortcode option? I am building this for somebody and he will struggle with adding variables in the post itself. I liked the idea that with this plugin you can just tick the option you want in the post, and it will display in the front end.

  9. Bareman
    Member
    Posted 5 years ago #

    or can [cft format=0] somehow be embedded in the index.php instead of manually adding it to each post?

  10. MichaelH
    Member
    Posted 5 years ago #

    I believe, if you want the custom fields displayed for every post then you will want to read my comments above about Using_Custom_Fields etc.

    If you are wanting to display a custom field as a link:
    http://selfconclusion.co.uk/2008/12/wp-custom-fields/

  11. Dgold
    Member
    Posted 5 years ago #

    The shortcode method, I believe, is for displaying the value inside the post (in the post content).

    The more traditional way is to use WordPress codes - such as the_meta - to call in your custom fields within your theme's templates, but outside the body of the post. Doing this, no one does anything special to "display" the fields when you write a post. Just fill in the custom fields (fill in the email box of Custom Fields Templates), and it will appear where-ever you have placed the_meta

    Note that the_meta displays all Key-Value combinations.
    Email -
    Phone -
    Thumbnail image -
    etc.

    If you just want to display a particular one, then consult the specific codes in the links MichaelH gave, or try another plugin: Get Custom Fields plugin.

  12. JohnathanNYC
    Member
    Posted 5 years ago #

    Sorry to put this in the thread, not sure what else to do.

    Dgold, could you contact me? http://www.johnathanandersendesign.com/contact/ I'd like to see if you have discovered any work-arounds to the Checkbox List custom field. I read your comments at ImpressLab.com and I'm looking for the same thing. I found an update to rc_custom_field_gui, but the checkbox functionality is broken. See: http://www.seoclear.com/2007/09/24/add-permanent-custom-fields-to-your-wordpress-write-page/

    Thanks

  13. Dgold
    Member
    Posted 5 years ago #

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

    it has the checkbox list feature now

Topic Closed

This topic has been closed to new replies.

About this Topic