Support » Fixing WordPress » Custom fields: Using ‘key’ with empty ‘value’ ???

  • Hope I can explain this correctly: Until now I had made 4 extra categories (like ‘interactive’, ‘sound’ etc.). These were not actual main categories but I used them to indicate if a post was something to read, hear, view or do. For this I have 4 little icons that, by assigning a post to one or more of these categories, will automatically appear next to a post, just like plugins of that kind. But other then in the case of the plugins that do this, my extra 4 categories aren’t ‘real’.

    This works ok, but I’m alway having difficulty of excluding those 4 categories from all kinds of listings and, especially, all sorts of plugins I use.

    Therefore I was experimenting with the custom fields. This also works, by using 4 custom fields with the same names as previously the categories. So when adding a post, I also add one or more of those custom fields. But it’s not really userfriendly because I also have to add something (doesn’t matter what) to the ‘values’ field, otherwise the custom field will not be excepted by wordpress.

    Any idea of changing this or some other suggestion? At this moment I’m using this code:

    $extravelden = get_post_custom_keys();
    $aantalvelden = count($extravelden);
    if ($aantalvelden != 0) {
    for ($i=0;$i<=$aantalvelden;$i++) {
    echo "<img src=\"plaatjes/".$extravelden[$i].".gif\" alt=\"\" />";

Viewing 7 replies - 1 through 7 (of 7 total)
  • No one? 🙁

    In short my question was: When adding a custom field, can I just add the ‘key’ without giving it a ‘value’?

    Learn from the plugin “Adhesive.”

    I looked at the code of this plugin and understand what’s it doing. It adds a value of ‘1’ to the meta-key ‘sticky’. So it’s not possible to just use a meta-key without adding a value. WordPress will not accept that and will not save the custom field.

    I can see that it should be possible to make some default custom fields, all with the value of 1, if they are checked in the ‘write post’ screen, just like the sticky. But I’m afraid that’s over my head. I don’t see how I can make something like that myself. 🙁

    But thanks for the tip.

    check out post_keywords, written by Ryan Boren, modified slightly for 1.5 by myself. it will add an extra input field for a “keyword” field. It is in essence apart of the custom field setup, as its value gets saved in the postmeta table (dont remember the exact name). It probably can be easily modified to add multiple inputs or change the fields name from keyword to “type” or “kind” …

    I really appreciate all the tips, … but I’m not so into php and mysql to see how I could use it to create my own thing. And this plugin by rboren is something I’m already using as a customfield. But what I would want is to create a few custom fields that I don’t need to fill in, but that have checkboxes above the post editing screen, just like when you’re using ‘sticky’ or ‘adhesive’ of ‘runphp’ plugin. Checking one checkbox ‘activates’ that custom field.

    In short I would like this: Above the post 4 checkboxes: ‘sound’, ‘movie’, ‘interactive’ and ‘enlarge’. These are not categories but more characteristics of that post. Clicking ‘interactive’ would cause a small if-statement in the indexpage to place a small icon of a mouse next to the title. If you visit my site you can see what I mean. But now I’m using 4 categories and I don’t want that anymore.

    let me see what i can come up with

    I would really appreciate that. Just hope I was clear enough about what I’m looking for :). Therefore one little addition to the above:
    When clicking that checkbox means an icon will appear next to the post title that will inform the visitor that sound has been added to that post, or that the thumbnail can be enlarged, or that it contains a moviesample, or that it contains some interactive element. So it’s kind of saying what properties a post has, other than saying to which category it belongs. Could be a hint for a very usefull plugin 🙂 🙂

    One example that has a combination of two of those options is this post:

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom fields: Using ‘key’ with empty ‘value’ ???’ is closed to new replies.