PHP In The Only When Necessary

Jim,

I heard that every PHP in the head rquires a trip to the database of a website (ie wordpress website). The busier the server is and the more PHP, the longer it will take to bring up a website, so ther only need to use PHP if some data is changing quickly (like time) that PHP is being used to keep track of, or if the different pages have different information (like title of the pages). If the information is static (ie content type, character set, version, address of CSS) , then it’s better not to use PHP. For example

<head>

<meta http-equiv="Content-Type" content="<?php bloginfo(‘html_type’); ?>; charset=<?php bloginfo(‘charset’); ?>" />

<title><?php bloginfo(‘name’); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>

<meta name="generator" content="WordPress <?php bloginfo(‘version’); ?>" />

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

<link rel="pingback" href="<?php bloginfo(‘pingback_url’); ?>" />

<?php wp_get_archives(‘type=monthly&format=link’); ?>

<?php wp_get_archives(‘type=monthly&format=link’); ?>

</head>

The first line I changed to

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

The second line I didn’t change becaue each of my pages has different titles.

Third line I changed to

<meta name="generator" content="WordPress 2.5.1" /> and every time the version changes I changed the code.

The fouth line I changed to

<link rel="stylesheet" href="http://www.actualcures dotcom/wp-content/themes/actualcures/style.css" type="text/css" media="screen" />

The fifth I changed to

<link rel="pingback" href="http://www.actualcures dotcom/xmlrpc.php" />

Would I leave the sixth line since it involves time (a form of change) so would I leave that as PHP. What does it do anyway?

Thanks,

Roger

Comments

  1. Actual says:

    Jim,
    The translations from PHP back to HTMl above were relatively easy, all I had to do is look at the <head> of the page in View, Page Source and the PHP is already processed into HTML, but in the footer I have

    <?php wp_footer(); ?>
    </body>
    </html>

    Since the footers are the same for all pages, what does that look like in HTML. View, Page Source doesn’t show anything.

    Thanks,

    Roger

  2. AMPC says:

    Hi Roger,

    wp_footer() is a function used by plugins to insert code after everything else on your webpage, kind of like a marker, so leave that, there is nothing more you can do with it.

    Regards,

    Jim.

  3. Actual says:

    Jim,
    What doe this line do?
    <?php wp_get_archives(‘type=monthly&format=link’); ?>

    Since the code looks like it’s information that changes, I assume you would leave it in PHP form.

    Roger

  4. AMPC says:

    Roger,

    Get_Archives() is a function that shows a list of your archives and can be used on any of your templates.

    There are a ton of options that can be used with wp_get_archives, such as those listed on this page:

    Regards,

    Jim.

  5. Actual says:

    Jim,
    <link rel="EditURI" type="application/rsd+xml" title="RSD" href="actualcures dotcom/xmlrpc.php?rsd" />
    <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="actualcures dotcom/wp-includes/wlwmanifest.xml" />

    are these commands for changing information?

    I think they cam from the PHP command <?php wp_head(); ?>

    In other words should I leave <?php wp_head(); ?> or can I change it to the 2 link rel lines above?

    Thanks Jim,

    Roger

  6. Actual says:

    Jim,
    I removd <?php wp_head(); ?> and it not only removed those two link rel lines but it also removed

    <!– Powered by AdSense-Deluxe WordPress Plugin v0.8 – acmetech.com/blog/adsense-deluxe/ –>

    <!– all in one seo pack 1.4.6.13 [-1,-1] –>
    and the title and the description so I had to put the line back in.

    Roger

  7. Actual says:

    Jim,
    Today I noticed my site has
    <title><?php bloginfo(‘name’); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?>

    Which is the original code (I didn’t make any changes to it)

    and now I see a line I don’t remeber seeing 2 lines down.
    <?php wp_title(); ?></title>

    What does this line do?

    Roger

  8. Actual says:

    Jim,
    Someone told me that <?php wp_title(); ?></title> prints the title of your blog. Strange that someone would hack in and do something like that.
    Print where, is it useful to have it?

    In converting php back to html usually you have for php
    link rel="pingback" href="<?php bloginfo….
    or
    <meta name="generator" content="WordPress <?php bloginfo
    and it’s easy to take the php out and put the info or address in after the = sign.

    So how do you convert this line back to html

    <div class="bottombox"><?php comments_template(); ?> </div> ?

    There’s no = or href= .

    Thanks Jim,

    Roger

Speak Your Mind

Comment moderation is enabled. Your comment may take some time to appear.