Currently, there is no option to have unique Full Background Image for every Post Category. The theme will use the “Background Pattern” set from the Theme Options panel for the Post Category pages.

If you’ll look in to “theme-styles.php” file located inside “inc” folder, you’ll see from lines 892 to 937 the logic behind the Full Background Image rendering. What it does is that it gets the “page ID” of the currently viewed page and see if it has a Full Background Image set by the user. However, a Post Category page doesn’t have any “Edit” page to begin with. So, what you can do is to edit it manually and create some form of “page identification” of the currently viewed Category page :

1.) In your “header.php”, search for this line of code:

<link rel='stylesheet' type='text/css' data-name="demo-style" href="<?php echo home_url(); ?>/?theme-styles=css&page_id=<?php echo $page_id; ?>" />

And replace it with this one:

<?php if(is_category()): ?>
    <link rel='stylesheet' type='text/css' data-name="demo-style" href="<?php echo home_url(); ?>/?theme-styles=css&page_id=<?php echo $page_id; ?>&category=true" /> 
<?php else: ?>    
    <link rel='stylesheet' type='text/css' data-name="demo-style" href="<?php echo home_url(); ?>/?theme-styles=css&page_id=<?php echo $page_id; ?>" /> 
<?php endif; ?>

What the code above does is that it checks if the currently viewed page is a “Category Page”, it appends a “category=true” string at the end of the called stylesheet “theme-styles.php” file.

2.) So, we now know if a currently viewed page is a “Category page” or not. If is is a “Category page”, then the following code will execute ( IMPORTANT : PASTE THIS CODE ON LINE 909 of “theme-styles.php” located on “inc/” folder):

<?php if(isset($_GET['category'])): ?>

    <?php     

    switch ($page_id) {
        case "7":
            $full_bg_image_url = 'http://yoursite.com/wp-content/themes/morphis/images/yourfullbackgroundimage_for_Category_with_page_ID_7.jpg';
            break;
        case "8":
            $full_bg_image_url = 'http://yoursite.com/wp-content/themes/morphis/images/yourfullbackgroundimage_for_Category_with_page_ID_8.jpg';
            break;
        case "9":
            $full_bg_image_url = 'http://yoursite.com/wp-content/themes/morphis/images/yourfullbackgroundimage_for_Category_with_page_ID_9.jpg';
            break;
    }

?>

<?php endif; ?>

So, the above code just see if the currently viewed page is a “Category Page” and uses a “switch” case statement to determine which category archive page is being viewed. For example, i am viewing a “toys” category archive which has a $page_id of “7”. So, naturally, it will use the image “http://yoursite.com/wp-content/themes/morphis/images/yourfullbackgroundimage_for_Category_with_page_ID_7.jpg”.

So, there you have it, just a simple mechanism for having a unique Full Background Image to each Post Category.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)