Ready to get started?Download WordPress


Inserting a header image PHP (6 posts)

  1. ehjacks
    Posted 5 years ago #

    Hey, Thanks for taking a look

    I am looking to insert a header image into my theme.(As well as make it random;
    <img src="http://path_to_images/headerimage_<?php echo(rand(1,3)); ?>.gif"
    width="image_width" height="image_height" alt="image_alt_text" />)

    I am wondering how to do this, as well as the best place to store the header image file in my database.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes() ?>>
    <head profile="http://gmpg.org/xfn/11">
    <title><?php bloginfo('name'); if ( is_404() ) : _e(' » ', 'sandbox'); _e('Not Found', 'sandbox'); elseif ( is_home() ) : _e(' » ', 'sandbox'); bloginfo('description'); else : wp_title(); endif; ?></title>
    <meta http-equiv="content-type" content="<?php bloginfo('html_type') ?>; charset=<?php bloginfo('charset') ?>" />
    <meta name="description" content="<?php bloginfo('description') ?>" />
    <meta name="generator" content="WordPress <?php bloginfo('version') ?>" /><!-- Please leave for stats -->

    <link rel="alternate" type="application/rss+xml" href="<?php bloginfo('rss2_url') ?>" title="<?php echo wp_specialchars(get_bloginfo('name'), 1) ?> <?php _e('Posts RSS feed', 'sandbox'); ?>" />
    <link rel="alternate" type="application/rss+xml" href="<?php bloginfo('comments_rss2_url') ?>" title="<?php echo wp_specialchars(get_bloginfo('name'), 1) ?> <?php _e('Comments RSS feed', 'sandbox'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url') ?>" />

    <!-- for reset/generic csss -->
    <style type="text/css" media="all"> @import url(<?php bloginfo('template_url'); ?>/css/reset.css); @import url(<?php bloginfo('template_url'); ?>/css/generic.css); </style>
    <style type="text/css" media="print"> @import url(<?php bloginfo('template_url'); ?>/css/print.css); </style>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />
    <!--[if lt IE 8]>
    <style type="text/css" media="all"> @import url(<?php bloginfo('template_url'); ?>/css/ie.css); </style>
    <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js" type="text/javascript"></script>

    <?php wp_head() ?>


    <body class="<?php sandbox_body_class() ?>">

    <div id="wrapper" class="hfeed">

    <div id="header">
    <h1 id="blog-title">/" title="<?php bloginfo('name') ?>" rel="home"><?php bloginfo('name'); ?></h1>
    <div id="blog-description"><?php bloginfo('description') ?></div>
    </div><!-- #header -->

  2. iridiax
    Posted 5 years ago #

  3. ehjacks
    Posted 5 years ago #

    Okay, thanks for the plugin advice. Now when it comes to inserting the header image into the header, how should I modify the header.php?

  4. iridiax
    Posted 5 years ago #

    how should I modify the header.php?

    I just download mine with ftp, edit it with a plain text editor, and then reupload it with ftp. You can also use the WordPress editor:


  5. ehjacks
    Posted 5 years ago #

    Yes ok, I can just use the built in editor. Where do you think I should insert the`code for the header image?

  6. iridiax
    Posted 5 years ago #

    Depending on which random header method/plugin you choose, it would either go after <div id="header"> and/or in #header in your theme's style.css. Check with the instructions for whatever you are using.

Topic Closed

This topic has been closed to new replies.

About this Topic