• I have a series of background images for the top banner of my blog. I’ve created a file, called css.php that poops out the CSS for the page, and includes a switch statement to swap out the URL for the banner each time the page is loaded.

    How do I tell WP to point at the .php file instead of the .css file? Do I need to hard-code it into the template? Do I need to go into the database and tinker with the bloginfo settings? The .php file will return the text/css header – but I have no idea how to point WP to the file.

Viewing 3 replies - 1 through 3 (of 3 total)
  • header.php in your template folder.

    However, I’d suggest keeping a static CSS file, style.css or whatever, and then manually adding in some CSS to the header of your document. Browsers usually cache external style sheets and so your header may not change. Plus, it’ll have to re-download the whole style sheet each time, costing bandwidth and load time.

    Here’s an example:

    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

    <style type="text/css" media="screen">

    #headerimage { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/[random image filename here]") repeat-x top center fixed; border: none; }

    </style>

    The file does the .css for the whole page? Why not just the logo/header?

    Does the .css change with every page load or just the logo?

    Thread Starter kuma_pageworks

    (@kuma_pageworks)

    I’m flogging the ‘Connections’ theme that I downloaded from WP. The image URL is in the CSS, not the PHP. I put a static link to css.php in index.php (which is where it started), and it changes every time you refresh the page.

    http://blog.kumapageworks.org

    I’m sure there are better ways to do it – but it works. I think maybe tomorrow I’ll split the CSS files into two imports to save bandwidth.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘css.php for dynamic content?’ is closed to new replies.