WordPress.org

Forums

Custom Fields (48 posts)

  1. khackett
    Member
    Posted 10 years ago #

    I know this has been oft discussed, but I still have NO idea how to do this. None of the instructions have been dumbed down enough for me. :)

    Could someone VERY VERY simply explain where to go/what to do?

    As of now, the best I can figure is that I have to edit each & every entry in order to make custom fields and even then, they don't show up.

    Help, please?

  2. Kafkaesqui

    Posted 10 years ago #

    The editing part is pretty much an individual affair, since what you place in the custom fields is up to you. If you're having issues here, provide some details into what you're using them for.

    As for how to display it:

    A very general way:
    http://codex.wordpress.org/Template_Tags/the_meta

    Some control over the process:
    http://www.coffee2code.com/archives/2004/06/30/plugin-get-custom/
    http://software.vtpaintball.net/wordpress/customMetaDisplay.php

  3. khackett
    Member
    Posted 10 years ago #

    Unfortunately, that's all ...Chinese to me. I just do not understand it.

  4. Kafkaesqui

    Posted 10 years ago #

    As I can't even write Chinese...ok, maybe a little Mandarin. :)

    Since your blog has been customized, I'll assume you have some knowledge with editing your WordPress template file(s). So to the point:

    Using the the_meta() tag (first link above), you insert something like the following -- wherever you want the data from the custom fields to display -- within The Loop found in your index.php template:

    <?php the_meta(); ?>

    This would output a simple unordered list of every "Key: Value" custom, or meta, field associated with a post. If your intent is to use custom fields to associate key words with a post, or provide an information marker to things like mood or calorie intake or whatever, then the built-in the_meta() tag may be all you need. However, a basic list of a post's custom fields is not what everyone is looking for, hence the two additional links leading to plugins that give you more control over how to use and display them.

    If you need more info, you'll have to help out a bit in return and fill us in on what you want to do with custom fields.

  5. khackett
    Member
    Posted 10 years ago #

    Wow, still don't get it.

    Basically, I want things like a field for what I'm listening to on iTunes, eating, wearing, doing, reading, that sort of stuff.

    I honestly do not have any (ANY) clue what a meta this and other stuff are/is.

    I'm also losing patience. Forgive if I sound short.

  6. Kafkaesqui

    Posted 10 years ago #

    One good point about the forums is, sound doesn't travel over them very well...

    When I say meta, meta data, or post meta (how it's referred to in WPland) just think "anything I enter in my custom fields". It's considered meta in a narrow sense, but that sense means: what you enter in custom fields can be anything you want. You choose what they are, decide what they represent, control how they're used.

    Meta. Custom fields. For this little discussion, they mean exactly the same thing.

    Being that what you enter in custom fields can be anything, this makes them harder to use than if there was a few buttons to press and your current playlist or library holdings displayed on your blog. Part of the reason for this is, not everyone uses the data in custom fields for displaying information. The only real limit to their use is, each custom field entry is tied to a specific post.

    Now, a key question I think will cut through some of the confusion: Do custom fields fulfill what you're looking to do? What I mean is, do you need to relate those things with a specific post? If there's a historical purpose, such as keeping track of when you were listening to a song or reading a certain book, perhaps it does. If not, then maybe something outside of the standard WordPress toolset may be in order. Something like this plugin:

    http://www.matt.blis.co.uk/archives/2004/12/02/mystuff-plugin-02-released/

  7. thegreatnorth
    Member
    Posted 10 years ago #

    To simplify:
    place this code: <?php the_meta(); ?> in your index.php template somewhere in the "entry" section and then when you create a new post with a key of "Listening To" value of "The Tragically Hip" it will show up in your post.
    The key of "Listening To" will now be saved as part of your post and could someday be used in the future.

    There is a lot more that can be done with this but this is it in its basic form.

  8. khackett
    Member
    Posted 10 years ago #

    But how do I go about changing those values? If I put a "Listening To:" code in, I'm not listening to the same song each entry. How do I change the song?

  9. Minna
    Member
    Posted 10 years ago #

    When you make your first custom field for a post (pick a post, any post) the *key* (i.e. "Listening", "Reading",...) will be stored for future use. The *value* (i.e. "Britney Spears", "WP documentation",...) of the custom field will be stored only for that chosen post thus you'll have to enter a value (if you want) for each post.

  10. khackett
    Member
    Posted 10 years ago #

    So in the normal entry mode there will be a place for me to write in whatever it is I want? Or do I have to do an Advanced Edit for every entry?

    (thank you again, I'm veeeeeeeery php illiterate)

  11. khackett
    Member
    Posted 10 years ago #

    Also, the MyStuff plugin doesn't work for me; it says the files don't exist (I put them where they needed to go).

  12. Minna
    Member
    Posted 10 years ago #

    In 1.5-beta-1 the custom fields are advanced editing as they seem to be in 1.2, too. So yes, you'd have to do Advanced Edit every time. But do change your setting at "Options > Writing > When starting a post, show:" to "Advanced controls", all the fun stuff is there anyway :)

  13. Minna
    Member
    Posted 10 years ago #

    I've also had problems with MyStuff and gave up on them so I can't help you with that one.

  14. khackett
    Member
    Posted 10 years ago #

    There is a custom field dealie at the bottom now. Do I just need to put in a code to make it/them show up on the index or is there more to be done?

    Also, how do I upgrade without having to uninstall/reinstall? (sorry sorrysorry!!!)

  15. Minna
    Member
    Posted 10 years ago #

    I think that <?php the_meta(); ?> is the tag to use to get the custom fields showing. If you don't want to show all custom fields (some plugins make their own additions that aren't supposed to show) you should check out Get Custom Field Values plugin to pick out the fields you want.

    There're upgrading instructions in the WP readme (come with the zip file) but I'm pretty sure someone has written better instructions telling one should remove all the files first. I actually upgraded by leaving only wp-config.php (database information) behind and uploading everything else but I'm not sure if that's the right way to go. Someone more informed can help you with that.

  16. khackett
    Member
    Posted 10 years ago #

    Great, thank you so much, Minna.

    So each time I want to put in a field, I write both the name of the field AND what goes in it. Am I correct?

  17. khackett
    Member
    Posted 10 years ago #

    Whoa.

    So I have a place for the plugin, although I'm not sure the plugin DID anything, but I have to manually write "Listening to: Whatever" every entry. But there is a dropdown menu to the side, it just does nothing... weird? Or normal?

  18. Minna
    Member
    Posted 10 years ago #

    You *can* choose the name of the field from that drop down list if you've made a custom field with that name already. And then you write the value in the value box. Be sure to either "Add custom field" or save a post.

    The plugin will allow you to pick out the specific fields you want to show, but if you don't have any extra fields (as I mentioned, plugins may add those) you can use the_meta tag.

  19. khackett
    Member
    Posted 10 years ago #

    Kay, I'm going to give an entry a go and see if this works. Thank you all for being so ...explainy! :)

  20. khackett
    Member
    Posted 10 years ago #

    Okay, I have it in there and it works, but the fields come off in one line instead of a little aside or something. A la:

    Listening To: Whatever Reading: Yadad Writing: ETc.

    I'd prefer:

    Listening:
    Reading:
    Whatevering:

    This also sort of hinges on getting 1 entry per page & the bloody next/previous thing to work, so...any help with both would be good.

  21. Minna
    Member
    Posted 10 years ago #

    Are you using the_meta? Or the plugin's output?

    How does it mess with paging and entry per page?

  22. khackett
    Member
    Posted 10 years ago #

    It doesn't mess with it, I just can't figure out how to get 1 entry per page & previous/next links.

    And I put a meta thingy into the code... I don't think I'm even using a plugin.

  23. Minna
    Member
    Posted 10 years ago #

    Ok, you need to have "posts paged" selected in Options > Reading > Front page: show the most recent.
    The prev/next links are done with <?php posts_nav_link('separator','previous','next'); ?>, write the values you like instead of separator, previous and next. Place the code outside the loop, i.e. somewhere after <?php endif; ?>

    As for the custom fields, they are in a list and the list has a class specified to it, post-meta. You have .meta li, ul.post-meta li { display: inline; } in your style sheet. Remove the ul.post-meta li.

  24. khackett
    Member
    Posted 10 years ago #

    Thanks :) Unfortunately, now I have an even BIGGER problem than the meta stuff.

    Parse error: parse error, unexpected T_ENDIF in /home/katehack/public_html/wordpress/index.php on line 118

    Whoa.

  25. Minna
    Member
    Posted 10 years ago #

    do you have any text editor where you could see the line numbers and tell what's on that line (and a few lines around it)? There's something wrong with the <?php endif; ?>. You did have that in the index file already? That you didn't insert it? Cause I don't remember what the original WP index was like so I don't know if I've modified mine "too much"

  26. khackett
    Member
    Posted 10 years ago #

    I plugged it into Dreamweaver and the line in question is the line you said. The <?php endif; ?> ....I had it in there originally, I never added it. I'm not sure what the bloody heck I did.

  27. Minna
    Member
    Posted 10 years ago #

    and you put the posts_nav_link after that endif tag?

  28. khackett
    Member
    Posted 10 years ago #

    I did. I removed them for the time being. I had the previous/next tags working for ...3 seconds. Then I did SOMETHING (I have NO idea what) and it ...went dead.

  29. carthik
    Member
    Posted 10 years ago #

    What about opening a new thread for the new problem? A lot more people will be willing to help if the problem is adequately described, and the forum post title is meaningful.

    I created http://codex.wordpress.org/Using_Custom_Fields to help users understand custom fields better. Please add to it, and make it better :)

  30. Minna
    Member
    Posted 10 years ago #

    Here's a snippet of the original WP index with the posts_nav_link added:
    <?php endforeach; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    <p align="center">
    <?php posts_nav_link(' � ', __('« Previous'), __('Next »')); ?>
    </p>
    </div> <!-- content div -->

Topic Closed

This topic has been closed to new replies.

About this Topic