WordPress.org

Ready to get started?Download WordPress

Forums

Plugin: Get Custom (36 posts)

  1. Hortalonus
    Member
    Posted 10 years ago #

    Nice plugin... I like it!

  2. guard952
    Member
    Posted 10 years ago #

    I found a bug in this code, see the fix here

  3. Scott Reilly
    WordPress & Plugin Dev
    Posted 10 years ago #

    The package has been updated to address the aforementioned bug.
    -Scott

  4. haguremetaru
    Member
    Posted 10 years ago #

    Great plug. I was wondering though... as an avid user of the bookmarklet, how would I be able to to combine these 2 elements?

  5. debwire
    Member
    Posted 10 years ago #

    I would love to see an example of this being used. Is anyone using this on their blog?

  6. Anonymous
    Unregistered
    Posted 10 years ago #

    whoops press the wrong key for backticks... silly little keyboard (12" Powerbook G4) there isnt even a # key...

  7. Scott Reilly
    WordPress & Plugin Dev
    Posted 10 years ago #

    debwire: Any sort of specific example you were looking to see of its use?
    Anon: Sounds like you've outlined the steps pretty well. Are you certain you've added the custom field to your post? Go back to edit the post and see if there is a custom fields section above the section "Add a new custom field to this post:". It should already have the key 'mood' there, with the mood you provided in the Value field, along with options to Update or Delete the custom field.
    The first time you create a custom field 'key', you have to define it, give it a value, and then press "Add Custom Field". Subsequent uses only require you to select the custom field via the dropdown and give it a value.

  8. Scott Reilly
    WordPress & Plugin Dev
    Posted 10 years ago #

    Ohhh, you have to echo the result so it will display:
    <?php echo get_custom('mood', 'Current mood :'); ?>

  9. Anonymous
    Unregistered
    Posted 10 years ago #

    well thanks for the quick reply, however when i enter mood into the key box and happy into the value one and then click add custom field the page refreshs and is blank again, according to your comment that shouldn't be the case.
    -shhcotty

  10. Anonymous
    Unregistered
    Posted 10 years ago #

    lol, right after saying that i entered the value first and then the key then clicked add and has appeared to work.. i did notice depending on which one you click first the size of the boxes alter. And i can now see a drop-down box :) thank-you for time and patience
    -shhcotty

  11. Anonymous
    Unregistered
    Posted 10 years ago #

    it appears to be working fine but only on posts following the installation of the plugin, awell guess I'm lucky that im only testing this out on my apache webserver. Where exactly is this data stored? Would it be possible to use it for calculations.. such as I could add daily Ice Lolly count then on my sidebar have the total Ice Lollies Consumed.....
    -shhcotty

  12. Scott Reilly
    WordPress & Plugin Dev
    Posted 10 years ago #

    Actually, I was incorrect. You don't have to press "Add Custom Field". When you save and/or publish your post, it'll automatically pick up a custom field you had one defined. When you pressed "Add custom field", it is apparently the same as pressing "Save". Which then refreshes the page and starts you on a NEW post. Go back and edit the original post, (or make another post and 'mood' should be in a dropdown box of available custom field keys). Sorry for the confusion.

  13. Anonymous
    Unregistered
    Posted 10 years ago #

    Right worked it out, set my blog entry to draft then enter the value (that appears blank when typed in, this a bug??) then select the key then click add custom field !

  14. planetphillip
    Member
    Posted 10 years ago #

    Hi,
    I don't use WP as a blog but more of a CMS. The posts are not really date dependant and I often update old posts. I would like to be able to have a section in my menu after Recent Posts called Updated Posts, that lists the last n posts that I have updated.
    I have created a custom field called, yes you guessed it, UPDATED and added the value TRUE.
    Is this possible with this plugin? If so, can somebody help me with the code?
    TIA
    Phillip

  15. zadu
    Member
    Posted 10 years ago #

    Phillip, this is a really unusual use of WP. I'm impressed. Shame I'm not into games :-) Anyway, I can't help with the database stuff but I'm just wondering why you would use a special field to indicate when a post is updated? Surely you could just edit the timestamp, so the most recent changes would be listed along with the most recent additions?

  16. planetphillip
    Member
    Posted 10 years ago #

    Zadu,
    I did think of that but by doing that it would put the updated posts on the index page and I didn't want to force my readers to have to read old posts that may only contain a few minor changes.
    I'm also worried that if I update a post that is two months old and a reader comes by once every two months they may think that nothing has changed.
    Your post got me thinking if there was a simple way of displaying the updated posts and I may make a new category called updated and just put them in there.
    Thanks
    Phillip

  17. zadu
    Member
    Posted 10 years ago #

    Another reason why I would not use a custom field is that unless you eventually remove the "updated" mark you'll end up with an ever-growing list of updated posts instead of just the most recently changed ones, which IMO would be more desirable.
    I think there is another way, but don't ask me how to code it up. Looking at the "wp-posts" table in my WP database, I see there is a field called post_date and another called post_date_gmt. These usually contain the same value, except for posts on which I edited the timestamp. In that case, post_date_gmt has the original date while post_date has the new (edited) date. The Loop in index.php seems to sort posts by post_date. If you create a modified Loop that sorts by post_date_gmt instead and stick that in another file, say recent-changes.php, that might just be the perfect solution for you. Unfortunately my coding is not that hot, so it would probably take me 3 full days to do that without breaking something else. But if you know your SQL and PHP you could probably do it much much faster than that.

  18. Scott Reilly
    WordPress & Plugin Dev
    Posted 10 years ago #

    WordPress already automatically tracks the lastest modification/update date for a post (separate from the original publication date). There is at least a plugin or two that can get that value for you easily. Though, speak of the devil, probably tomorrow I will be releasing a plugin that will allow you to easily display a list of updated posts (and much, much more).

  19. lokrin
    Member
    Posted 9 years ago #

    Darn, I guess I didn't save that last message. One problem with working with a dozen pagesat one time.
    Anyway, I have the plugin installed and actvated, andI added the code to index.php:
    <?php echo get_custom('bg', 'Blood Sugar level :'); ?>
    But then the site breaks with an error of:
    Fatal error: Call to undefined function: get_custom() in /.../.../.../weblog/index.php on line 65
    (path editied)
    Anyway, I added the field on the edit page and the added field shows and it is also in the dropdown box.
    What am I doing wrong or not doing?
    BTW - I also have moody installed and it works perfectly, giving me a mood icon (animated).
    Thanks.

  20. lokrin
    Member
    Posted 9 years ago #

    Thanks, that was it, such a little change that I overlooked it.
    c2c_get_custom
    get_custom
    It is now woring.
    :-*
    By the way, the official link is:
    http://wordpress.org/support/10/8342
    I'll move to there...

  21. lokrin
    Member
    Posted 9 years ago #

    OOps, that IS this link..... I know there is also another discussion on this around here somewhere, because I found that one doing a search...

  22. lokrin
    Member
    Posted 9 years ago #

    <blather>
    Ok, new question - Is the following possible? I'm not that great in php but I understand it enough to play around and pervert the code to my own desires. *leer*
    (WordPress, phpBB and my own website use a lot of php, so I'm learning as I go. My website uses them mostly as includes for headers and footers, but I also have php in my external CSS files for colour coding, since I USE A LOT OF COLOURS IN A LOT OF CSS TAGS AND IT'S EASIER THE CHANGE THE VALUES THREE TIMES RATHER THAN AROUND TWENTY OR SO.)
    #@$&$ frigging caps lock key.. =P
    Anyway, my custom field is for blood sugar level. I'm a diabetic. My weblog deals with that. Is it possible, with this plugin, and possibly CSS (Which I do know quite well) to do something to the effect of:
    if 100>=bg>=150 then font/or/background colour is green
    if 50>=bg>100 or 150>bg>=200 then font/or/background is yellow
    if bg>50 or 200>bg then font/or/background is red
    Or, add an icon, call them bggreen.gif, bgyellow.gif and bgred.gif and have those display ALONG with the actual text and number?
    For a quick look at my site: http://weblog.lokrin.net
    If I get this working it will give me more incentive to write more entries.
    :-)
    Thanks Y'all!
    (Main site is http://lokrin.net and I have WP as a major link in the footer :-)
    </blather>

  23. lokrin
    Member
    Posted 9 years ago #

    I know I could do it seperately with the following code (used as an example of post icons):
    <?php echo c2c_get_custom('bg_icon', '<img alt="bg level colour" class="bgicon" src="/wp-images/bgicons/', '.gif" />', 'blank'); ?>
    But I'm hoping to automate it a bit, unless it would be anunduly coding nightmare.
    =)

  24. Raven
    Member
    Posted 9 years ago #

    This was already asked in the thread, but I didn't see an answer. Is there a way to show the custom field in WP's bookmarklet?

  25. Plugin updated to v2.1

    Changes in this release:

    * Removed the $filter argument from c2c_get_custom() and c2c_get_recent_custom()

    * Replaced $filter argument with more robust filtering approach: filter every custom field via the action 'the_meta', filter specific custom fields via 'the_meta_$field'

    * Add argument $include_static (defaulted to true) to c2c_get_recent_custom(); static posts (i.e. "pages") can be optionally excluded from consideration

    * Verified to work for WP 1.5 (and should still work for WP 1.2)

    (looks like the earlier messages in this thread are missing... In the interest of explanation for those who may not know, this plugin allows for the easy retrieval and control of the display of any custom field values/meta data for posts, inside or outside "the loop". The power of custom fields gives this plugin the potential to be dozens of plugins all rolled into one.)

  26. fuelcell
    Member
    Posted 9 years ago #

    This is the most impressed I've been with a plug-in. I've read through the examples you give on your site. I'm gonna try the "per post" customized more.

    But what I'm most interested in is giving each post an image in the custom field and then calling it in a "recent posts" list on the sidebar. Is this possible with your plug-in? My gut tells me yeah but I can't wrap my feeble brain (haha) around it.

  27. fuelcell
    Member
    Posted 9 years ago #

    You know I almost seem to have this working except it just displays "post image" (the words) instead of the actual images. I clicked properties and it says blank.jpg. This because I was adapting your post_icon example. I have this nested in a show recent posts foreach loop. I guess the missing part is not telling it what post . . . ? So maybe this is not possible, after all.

    <?php
    foreach ($recentposts as $post) {
    if ($post->post_title == '')
    $post->post_title = sprintf(__('Post #%s'), $post->ID);
    echo "<li><a href='?p=$post->ID'>";
    the_title();
    echo '</a>';
    echo c2c_get_custom('post_image', '<img alt="post image" class="postimage" src="/wp-images/post_images/', '.jpg" />', 'blank');
    echo '</li>';
    }
    ?>
    </ul>
    <?php endif; ?>

    lol . . . i don't know what the heck I'm doing here. Just throwing shit at a wall to see what sticks.

  28. An update to the Customizable Post Listing plugin will allow you to display custom field data in a recent posts listing. A day or two and that'll be ready. It's been a long day so I can't concentrate on why your attempt above failed. Maybe before the foreach have this line:
    global $post;

  29. Lorelle
    Member
    Posted 9 years ago #

    And how about a link to it. It seems to gotten lost in the shuffle of threads.

  30. fuelcell
    Member
    Posted 9 years ago #

    *bump*

    Hmmm . . . how to subtly say "i really really want to see this update" without seeming pushy. : )

Topic Closed

This topic has been closed to new replies.

About this Topic