WordPress.org

Ready to get started?Download WordPress

Forums

Category background image (4 posts)

  1. marzar00
    Member
    Posted 10 years ago #

    Is there a code that lets you have a different background for each post depending on its category? I tryed with the category image script but it didn't work.
    Please help
    Marzar

  2. chuckg
    Member
    Posted 10 years ago #

    There isn't anything written at the moment that does what you're looking for, but I do not believe that it would be terribly hard to create something with the functionality you're looking for. Forgive me for not writing for you myself, but it's Friday, but the sun and tequila have taken their toll on me. I will, however, point you in the right direction.
    What you will wish to do is write a function like so:
    function post_back_ground($category = "general") {
    return "images/cat_background/". $category ."_background.jpg";
    }
    All you will have to do then is create a div tag which encompasses the entire post, say like this:
    <div style="background-image: top left <?php post_back_ground(the_category()) ?> no-repeat">##all the post text</div>
    Simply put an image per category name into some directory, ie we used /images/cat_background/(category_name)_background.jpg". Then, the function will simply set the background to whatever the name of the cat is of the div we set around the post .... I think that makes sense. If it doesn't, let me know and I'll write it tommorow when I'm less ... well drunk. I guess I should add my usual "voila", but I won't cause I'm not sure that works ;)

  3. Jinsan
    Member
    Posted 9 years ago #

    sorry to bump an old post, but could someone give a template for this as this si something I would like to do within 1.5beta.

    I can understand some of it, but honestly it looks a little....unclear?

    Thanks in advance

  4. msralls
    Member
    Posted 8 years ago #

    I would really like some help with this same thing. Has this been done since this post?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.