• In my blog, I normally like to include a “Quote of the Day.” Some people do “lesson of the day” or even “picture of the day.” I tweaked with some code to allow the use of the new meta fields to accomplish this task easily. On a post, create two meta fields. “otd_type” for what the _____ of the day is. Then put the content in an “otd_content”
    As long as pairs of otd_type and otd_content are entered sequentially, you can have as many in one post as you want. For stylesheet purposes, the div class “oftheday” and the span classes “typeOTD” and “contentOTD” are used. (For a “Picture of the Day,” simply put an IMG tag for the otd_content value.) I added the following function to wp-includes/template-functions-post.php :
    function get_otd() {
    global $id, $post_meta_cache;
    if (get_post_custom_keys()) {
    $types = array_map(‘trim’,$post_meta_cache[$id][‘otd_type’]);
    $stuff = array_map(‘trim’,$post_meta_cache[$id][‘otd_content’]);
    foreach ($types as $growl=>$value)
    {
    echo “<div class=’oftheday’>\n”;
    echo “<span class=’typeOTD’>{$types[$growl]} of the Day:</span>\n”;
    echo “<span class=’contentOTD’>{$stuff[$growl]}</span>\n”;
    echo “</div>\n”;
    }
    }
    }
    I am in the midst of migrating from a manually-maintained blog to WordPress, so my WP blog (https://diaries.gemini6ice.com/index.php) is not out-and-running yet. Before I publish it, I need to finish creating all the features (in a WP context) that I manually did before. Thanks for giving us meta fields, WP. Otherwise, I would have had to play with code I understand even less.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter gemini6ice

    (@gemini6ice)

    (I’m obviously new to the forums and know absolutely nothing about forum post formatting yet. Sorry. I just wanted to share what I managed to make work. ^_- )

    G,
    Welcome to WordPress. It looks like you are off to a terrific start, and thanks for sharing your code.
    Let us know when your site goes live, and be sure to visit the forums often.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘“_____ of the day”’ is closed to new replies.