• OK, so I know I can write a plugin that has the code:

    add_filter(‘bloginfo’, ‘strtoupper’);

    and all the bloginfo content will be set to uppercase (blog title, description, etc).

    But how do I change something specific, for instance what if I wanted *only* the description from bloginfo to be uppercase?

Viewing 4 replies - 1 through 4 (of 4 total)
  • function toUpperBlogDescription($info, $show) {
    if ($show == 'blogdescription') {
    $info = strtoupper($info);
    }
    return $info;
    }

    add_filter('bloginfo', 'toUpperBlogDescription')

    Off the top of my head, something like that minus the error if any.

    Thread Starter fncll

    (@fncll)

    This gives an error looking for the second argument for toUpperBlogDescription…

    I’m not sure if this code actually is doing what I am wanting to do, which is change the specific call to bloginfo(‘description’) rather than every instance of the bloginfo() function (which is built-in to PHP)

    function toUpperBlogDescription($info, $show) {
    if ($show == 'description') {
    $info = strtoupper($info);
    }
    return $info;
    }

    //add_filter('filter_name', 'filter_func', priority, number of arguments)
    add_filter('bloginfo', 'toUpperBlogDescription', 10, 2);

    The filter function toUpperBlogDescription is indeed invoked for every call to bloginfo; however, only if you retrieve the description then the output is converted to uppercase.

    Thread Starter fncll

    (@fncll)

    Thanks! That did it. That last parameter when you call add_filter (the number of arguments) wasn’t shown on the wiki pages I was using… and it of course makes all the difference 🙂

    I’m going to fix/update the wiki pages when I go back.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Basic Plugin Question’ is closed to new replies.