Webtrepreneur.co.za

Earn money online being a Web Entrepreneur

Archive for the ‘Code’ Category

Counting the reads of each post..

People who run blogs, and people who enjoy earning money online usually love statistics. I know, personally, that I check my keywords, traffic and revenue streams a couple times a day. I make sure that I know exactly which keywords and threads people are interested in, so that I can work my future posts around them. On top of this, people are like sheep, they follow what others do. If there is a post which has many comments on it, the chances are, other people will show interest to this thread rather than another thread.

Displaying the number of times a thread has been read, is a useful way to control the traffic coming to your website. This can be tied hand in hand with advert placement, and so much more.

In order to display the number of reads each of your articles has had is fairly straight forward, here is my example:

  • Download this plugin. Upload and activate it as per usual.
  • The next step is to create a table in your database, using the following code:

create table mostAccessed
(
postnumber int not null,
cntaccess int not null,
primary key(postnumber),
unique id(postnumber)
);

  • Open your single.php file and search for this code:
    • <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  • Directly under this code, add the following code:
    • <?php if ($id > 0) { add_count($id); } ?>
  • Now search for this code:
    • <?php the_title(); ?>
  • Directly underneath, add the following code:
    • <?php if (!( is_home() || is_page() )) { ?>
      <?php show_post_count($post->ID,
      $before=”This post has been viewed “,
      $after=”
      times since “); ?>
      <?php } ?>

That’s it! Follow these steps carefully. It is vital that you place the <?php if ($id > 0) { add_count($id); } ?> code in the single.php file and not in your index file. If you place the code in your index.php file, each time the page is loaded, each post will increase the read count, which is definitely not what we want. The second code snippet you deal with, can however be placed in your index.php file - this will show the reads per post in your home page for each article.

Good luck!

Maximizing Ad Impressions

If your webpages makes use of advertisements, you want to ensure that the most ads are displayed to your users. However, if users use the back button on their browser to navigate back on your site, chances are they won’t see a new ad on reloading an old page. You can overwrite these default settings by using one line of HTML code which will tell a user’s browser not to cache your page(s), thereby forcing them to reload the page again including viewing a new ad. Typically this tip should increase your advertising impressions by at least 15% if not greater, but be advised that a larger amount of bandwidth and resources will also be used to re-display the same webpages to web surfers. If your concerned about bandwidth conservation, do not apply the suggestions we make on this page.

HTML No-Cache Syntax

The cache setting can be controlled via three sets of META tags, “Expires”, “Pragma” and “Cache-Control”. Each of these META Tags will perform the same net effect and cause the web page to not be cached. The difference between each of them lies in the differences between how browsers interpret the results.

The “Expires” tag is an all browser tag which we recommend the most because it functions in all browsers and explicitly indicates to browsers that the page is to expire immediately and should therefore be reloaded now. In addition, webmasters have explicit control of defining exactly when a page will expire, whether it be now, in a few minutes or in a few months, this META Tag explicitly allows a set date for expiration. (Learn more about the Expires META Tag)

The “Pragma” tag only functions in Netscape browsers and for this reason we do not recommend its use since you essentially limit the ability to prevent caching to only Netscape users. The Pragma tag was specifically designed to interact with proxy servers that cache web sites into their local databases. It’s only option is to set the cache off if the tag is found, otherwise (if it is not found) it assumes that proxy caching is acceptable.

The “Cache-Control” tag specifies desired behaviour from a caching system and is understood by both clients and web servers. In order to prevent caching, the Cache-Control option should be set to “no-cache”. Our preference however still lies with the “Expires” tag simply because webmasters have more control and options of defining when a document will cease to be valid.

Sample Usage to Prevent Caching

Notice About These Implementations:
These cache prevention techniques override browsers’ cache settings which also means that each request will need to be re-issued which will cause an increase in bandwidth requirements. If your concerned about keeping bandwidth to a minimum, consider not using the techniques we cover on this page.

META Tag: “Expires”
General Usage: <META http-equiv=”Expires” content=”0″>
Benefit: Tells browsers that the document expires now and should force a reload of the document.
More Info: Learn more about the Expires Meta tag in our META tag guide which covers all the functionality of this META Tag including how to set expiration dates.
META Tag: “Pragma”
General Usage: <META http-equiv=”Pragma” content=”no-cache”>
Benefit: Prevents Netscape browsers from caching your webpages, thereby forcing webpages to be reloaded entirely including advertisements.
Comments: The Pragma META Tag is only understood by Netscape browsers, Internet Explorer will simply skip over this tag and not understand it.
META Tag: “Cache-Control”
General Usage: <META http-equiv=”Cache-Control” content=”no-cache”>
Benefit: Tells browsers that the page should not be cached and should always request and return the newest copy from the server.

Reference: Submit Corner

META Tag Usage

META Tags are the most important tags that search engines use to categorize, prioritize and rank your website. Meta tags provide a very concise fashion for website owners to categorize their site by the most appropriate keywords and descriptions. Because of the great flexibility in giving the opportunity for webmasters to categorize their webpages, this also opens up the issue of abuse. Bear in mind that search engines have algorithms to prevent abuse of excessive meta tags, so there are some general principles that webmasters should adhere to such as:

Keep META Tags Short But Concise

Many webmasters realize that search engines use Description and Keyword META tags heavily and try taking advantage of this by writing very long descriptions and keywords. Search engines have a finite database and will only index a certain portion of your website. Try to keep your META tags simple and to the point. Search engines take into account the number of occurrences of each tag and may penalize your website’s rankings if you overuse META tags.

Avoid Using All Upper Case (Caps)

Some search engines used to prioritize websites that started with capital letters or those that had special characters such as numbers. This technique may still work with some older search engines, but beware that search engines are constantly on the lookout for abusers.

Avoid “Bridge” Pages

Bridge pages are pages which redirect a user to another page, which is often the page that the webmaster intended a user to go to directly. This practice is strongly discouraged by search engines as it clutters their databases with useless pages and opens the opportunity for users to spam search engines with irrelevant pages. Bridge pages are mostly associated with the META Refresh Tag.

Prioritize Your Keywords

Some search engines will read only the first few lines of your webpages to get an overview of your website. Search engines which do this may miss some of your META tags. As such, you should put focus on your description and keywords META tags with priority on the first few words.

Avoid Repetition

Try to avoid repeating the same keywords or descriptions in your meta tags. Often, search engines will degrade your rankings when they detect repetition of the same words in your META Tags. Should you need to use repetition, separate the repeated words from each other by a few other keywords.

An example of META tag usage:

<META NAME=”keywords” CONTENT=”keywords, seperated, by, commas, 255, chars, maximum”>
<META NAME=”description” CONTENT=”Describe your website here, 255 characters maximum”>
<META HTTP-EQUIV=”Content-Language” CONTENT=”EN”>
<META NAME=”author” CONTENT=”Author Name Here, 75 characters maximum”>
<META NAME=”copyright” CONTENT=”Copyright statement, 255 characters”>
<META NAME=”robots” CONTENT=”FOLLOW,INDEX”>

Reference: Submit Corner

ALT Image Tags

If your website/blog uses images, image maps or pictures, you should always make use of the ALT tag. ALT tags are a property of the <img src> tag. It displays alternative text for users who cannot load images or have a problem loading an image. Search engines don’t see images, they read a website, so it’s a good idea to give your images a ALT description. In other words, giving your images alternative descriptions, will give search engines a verbal description of your images.

If your website/blog consits of a large number of images, it is vital to use alternative tags, as with many images, your content will probably be on a minimal side. A good image to always give an alterative tag to is the header image at the top of your website - this is often one of the first things a search engine will view.

The general layout of this tag is as follows:

<IMG SRC="image.ext" ALT="Alternative text in here">

An example would be:

<IMG SRC="header.jpg" ALT="Webtrepreneur Home Page">

The above example would give search engines a great idea of what the website is all above. I would suggest going a little further than my example above, and rather use the alternative tag to describe the website, like so:

<IMG SRC="header.jpg" ALT="Webtrepreneur making money online">

This will allow the search engine to understand your website right from the beginning. For Adsense users, this is a excellent way to get your adverts displaying relative media on a website with a large quantity of images.