rtober

Member

Forum Replies Created

  • In reply to: change header image on refresh

    #11627

    Andrew,

    Each page, post, comment, etc. gets a unique ID within WP that can be called from PHP functions like is_page(), etc. You don’t have to do anything other than declare the right ID number.

    The second half of the code change is edited in the same header.php file you modify with the logo. rand() .jpg code from above. Go down about 10 lines and find the same

    <div id="header" style="background-image:url(<?php echo

    add additional folder paths and customize the $header_img part to match the IF:THEN statements.

    In reply to: change header image on refresh

    #11625

    I hacked in some code to do this for my site. Created a child-theme first so I can edit theme files without loosing changes when Syahir updates his files. Created a folder with my logo .jpgs cut to 900×198 (or whatever your current header size is). Naming convention for all my logos are “name.N.jpg” where N = N+1. logo.1.jpg, logo.2.jpg, etc.

    Opened up my child header file and made the following changes:

    } else {
    /* RT: Custom header code for random images by page ID */
    /* $header_img = get_header_image(); */

    if ( is_page('19') ) {
    $header_img = "hike." . rand(1,7) . ".jpg";
    }
    elseif ( is_page('30') ) {
    $header_img = "archives." . rand(1,1) . ".jpg";
    }
    elseif ( is_page('359') ) {
    $header_img = "gators." . rand(1,2) .".jpg";
    }
    else {
    switch (date('md')){
    case "1031":
    $header_img = "logo.1.jpg";
    break;
    case "1122":
    $header_img = "logo.1.jpg";
    break;
    case "0214":
    $header_img = "logo.1.jpg";
    break;
    default:
    $header_img = "logo." . rand(1,35) . ".jpg";
    break;
    }
    }

    Then I made a change to:

    <!-- RT: Added custom path to background:url -->
    <div id="header" style="background-image:url(/images/logo_graphene/<?php echo $header_img; ?>);">
    <!-- RT: End custom code -->

    In a nut shell: for each page ID I declare, use a random .jpg for my header image each time you refresh the page. You can specify an image for a certain date, etc. It does require a bit of setup with your .jpgs and you have to make sure you insert your logo folder path into the div id statement. View your page source to debug.

    I’m sure there are easier ways to do this but it works if you want custom header image rotation independent of post/page images.

    Hope this helps.

    In reply to: Comment style element for post author

    #11603

    I think I found it. It looks like:

    <li id="comment-<?php comment_ID(); ?>" <?php comment_class('clearfix'); ?>>

    includes “bypostauthor” in the style string so I added:

    .bypostauthor {
    background-color: #F8FFB8 !important;
    }

    to my custom CSS and it looks like that’s taking care of it.

    One less plugin!

Viewing 3 posts - 1 through 3 (of 3 total)