Posts Tagged ‘Header Php’

How do you use WordPress to run a website?

WordPress is a blogging package right? Well if you think that you’re absolutely right but only partially. WordPress, which is most likely the worlds most popular blogging package is also a great piece of software to power small business websites. In fact, I’ve used WordPress to power websites such as:

In all of these cases as well as many, many others WordPress was used to create and manage complex websites which skyrocketed to the top of Google’s Search Engine Results Pages because they used WordPress as a powerful content management tool, making the website much easier to manage and therefore a better tool for busy marketing staff.

How do you use WordPress to run a website?

Actually, that’s the best part of WordPress. Once you’ve signed up for a great hosting package such as Bluehost’s $6.95 per month solution, you can install WordPress by simply clicking their one step installation process and voila! You’re website is setup with the world’s most powerful blogging package instantly.

So then, how do you use WordPress to run a website? Once you’ve installed WordPress you’ll need to make changes to a few key files, called template files. These template files are what control how your website looks to visitors. Here’s what you need to know:

  • The header.php file is what appears on all pages at the top of your page
  • The footer.php file is what appears on all pages at the bottom of your website
  • functions.php is where you store common PHP code to call if from all pages, most often you can ignore this
  • index.php is the heart and soul of your website, technically you can remove all the other .php files and format just this page to make every page on your website look the same.
  • pages.php is used to format content edited in the Pages tab of the WordPress control panel
  • single.php is used to format content edited in the Posts tab, by seperating these two you can format pages (such as About Us or Contact Us) to look different than content pages (such as a press release or CEO blog)
  • categories.php is used to format pages which list posts, archives.php is similar but for tags
  • search.php is used to format the results of a search

Once you’ve changed the look and feel of your website, you can use the built in WordPress editor to allow different members of your team to post content to the website, add marketing or press releases and even adjust prices!

You can get started with your company website today but signing up for a great hosting account, just $6.95 per month with BlueHost.

Securing WordPress against itself

As many bloggers have been learning lately, WordPress has a ton of major security holes being exploited by evil doers but because of the open nature of the tool, these exploits vary dramatically depending upon which version of the tool you’re using so one of the first tips we give WordPress blog owners is to remove the WordPress version number from your template file, this is pretty simple thing to do simply by opening the header.php file and searching for the line of HTML with your file which looks something like:

[source lang="html"]<meta name="generator" content="WordPress <?php bloginfo(‘version’); ?>" /> <!– leave this for stats –>[/source]

Unfortunately, this isn’t just good for stats … it’s great for hackers because it tells then exactly what version of WordPress you’re using which allows them to search the net for hacks specific to your version of WordPress. Unfortunately, as of version 2.5 the people at WordPress don’t simply allow you to remove this piece of code from your theme and forcibly “inject” the damning meta tag into your theme using the wp_head(); function which is required to make WordPress work.

There is luckily a fix, but it requires users to edit yet another file in their template directory. To truly remove the code, you’ll need to open the functions.php file and add the code:

[source lang="php"]remove_action(‘wp_head’, ‘wp_generator’); [/source]

How to exclude yourself from Google Analytics with WordPress

Without data we’re only guessing so it’s critical that we not only have great data to make decisions with but also that the data we do have is as free from corruption as possible. With that in mind if you run a WordPress website and Google Analytics, you’re most likely skewing your data without realizing it by visiting your own website.

To stop yourself from being counted as a visitor, all you need to do is add a simple piece of code to your websites header.php file that will read:

 

[source lang="php"]<?php
if (is_user_logged_in() == 1) {
if (wp_get_current_user()->ID == 1) {
setcookie("analyticsexcludeme", "analyticsexcludeme", time()+3600);
}
};
?>[/source]

Make sure the code is placed above the Google Analytics code (which I always like to place in the footer of my websites anyways). Once this code is placed in your header file, your website is updated but you’re not finished yet!

 

The code is only the first part, it’s what tells Google that you’d like to be excluded but now we need to actually exclude you.

Log into your Analytics account and click Analytics Settings.

Next, open the Filter manager (very bottom right corner).

Finally, add a new Filter with the settings:

analytics exclude me How to exclude yourself from Google Analytics with WordPress imageThis will tell Google to exclude all visitors who have the cookie “analyticsexcludeme” in their web browser, the same cookie we set earlier in the header code section of this tutorial.