WordPress.org

Forums

Filters and Changing Data (3 posts)

  1. DanDaMan
    Member
    Posted 9 years ago #

    Please pardon the probably rather easy question, but I am trying to wrap my head around this plugin authoring and I can't get it, I guess.

    I had this great idea of having a different image and an associated tagline appearing in the place of the blog's "description" field. I'm planning on having an image URL and the associated description pulled randomly and displayed on each page. In other words, I might have a U2 photo and the top of the page would say "My Blog: I think Bono is hot" or something silly like that. Then, if you reload, it might have a photo of Wallace and Gromit and then say "My Blog: Yeah, they're British puppets" or something.

    So I've managed to use the wp_head action hook to put a random bit of CSS in there to give the image. But I can't get the text. I know the description data is in the bloginfo() function, and it seems anyone can edit all of the bloginfo, but I guess I don't get how it's all stored. If I run this code, it replaces the title and many other things with the $random_text:

    function rand_head_desc($value) {
    global $random_text;
    return $random_text;
    }

    add_filter('bloginfo', 'rand_head_desc');

    Can I put 'bloginfo('description')' in the add_filter argument? Is it even possible to change the description? (I should think so, but I guess I don't really know.)

    Thanks for your help in advance. I hope I can build on this experience and start writing cool plug-ins.

    Dan

  2. DanDaMan
    Member
    Posted 9 years ago #

    Any ideas, please? I certainly don't have any besides making a custom template and I'd rather not do that. I want to learn this plug-in thing, it's just hard without the documentation for every detail. Please help me out if you know the answer.

  3. DanDaMan
    Member
    Posted 9 years ago #

    Well, this isn't the great solution I was looking for, but I guess I might just change the name of the variable and then edit my template to display my new variable instead of my description. Not as cool, but usable.

Topic Closed

This topic has been closed to new replies.

About this Topic