Change background for different post categories

Support Area Forums Foxy Change background for different post categories

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
URL to the page in question:
  • Author
    Posts
  • #8470
    Eddie May
    Participant

    Hi Bill,
    Is it possible to change the background image for ‘normal’ posts by category (ie, design, build, etc) or even by individual post?

    (I’m not using the Services feature, so can’t use service-groups approach)

    I saw in another post about using the featured image but that made no difference to me.

    FYI – Slide Enabled = Yes, One slide background image.

    Thanks,
    Eddie

    #8476
    Bill Robbins
    Moderator

    Eddie,

    Good question. The way to go about doing that without any editing, would be to use the same featured image for every post in a category. If you set the featured image and also choose the “Image” format, the featured image will be displayed in the background.

    If you’d like to do that programmatically, it can be done. Here’s what you’ll need to do:

    1. Go to the Media section of your WordPress control panel and select Add New.
    2. Upload the image you’d like to use for your category background. Once the upload finishes, WordPress will give you the URL to that image. Copy it.
    3. Next go to the Appearance section and select Edit.
    4. From the list of files on your right, choose custom-js.php
    5. Look for this spot:
      
      <?php elseif (is_archive() && of_get_option('archive_image', $single = true) != "" ): ?>
      {image : '<?php echo of_get_option('archive_image'); ?>'}
      
    6. Right above that paste this:
    7. Change Blog to the name of the category you’re working with. The change the http://www.organizedthemes.com/demo/foxy/files/2011/08/cafe.jpg to the URL of your image you copied earlier.
    8. Save your changes.

    That should give you a consistent background image for that category. You can repeat that for as many categories as you need to.

    If a post is in more than one category, I believe this will show the image for the first one you have listed in your code here.

    If you have any questions or trouble, just let me know,
    Bill

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Change background for different post categories’ is closed to new replies.