Ads 468x60px

Shoemoney - Skills To Pay The Bills

Shoemoney - Skills To Pay The Bills

Link to ShoeMoney Internet Marketing Blog

Free Shirt Friday – GreenPoop

Posted: 18 Jan 2013 05:00 AM PST

Post image for Free Shirt Friday – GreenPoop

This site is totally f*cking disgusting… but useful. GreenPoop will not only tell you what it means if your poop is green, but what it means if you have red poop, black poop, yellow poop, and even white poop. I know y’all are going to be looking at your poop now!

If you would like to see your website or company featured on Free Shirt Friday click here.

Looking for an SEO service that won’t get you banned?

Building an “Archives” Page with Simple PHP - DailyBlogTips

Building an “Archives” Page with Simple PHP - DailyBlogTips


Building an “Archives” Page with Simple PHP

Posted: 17 Jan 2013 07:23 AM PST

In my opinion most websites should have an HTML sitemap (also called “Archive” or “Archives”). That is basically a page that will contain a link to all other pages of the site. In case of a blog it will contain a link to all blog posts.

Such HTML sitemap is beneficial both for search engines and human visitors. Search engines benefit from it because it becomes easy to crawl all the content of the website. Human visitors, similarly, become able to quickly look for a post that was published on a particular month/day/year. On top of that there’s an SEO benefit, as your link juice will spread evenly across all pages.

In order to build such an “Archives” page I used to use and recommend a plugin called SGR Clean Archives. That plugin is quite old, however, and it stopped being updated a while ago.

Then a couple of days ago I received an email from a reader who took my recommendation and was using the plugin. He said that his server was becoming really slow lately, and upon further investigation they discovered that the plugin was hammering the server and causing the slowness.

He also pointed out that my own “Archives” page was not working anymore. Damn! My guess is that the latest versions of WordPress rendered the plugin’s code slow and ineffective.

Anyway I needed to find an alternative. Since performance was a crucial aspect here I decided to implement my own “Archives” page using raw PHP and WordPress functions. It turned out to be an easy task:

1. Create A Template

The first step was to create the page template I would use for the “Archives Page”. Basically I copied the structure of a normal page (usually page.php), and added the following piece of code on top:

<?php
/*
Template Name: Archives
*/
?>

2. Add the PHP code

After that I removed the piece of code that outputs the normal content:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(__('Read more'));?>
<?php endwhile; else: ?>
<?php endif; ?>

And substituted it with my own PHP code to output the links of all published posts:

<h1>Archives</h1>
<ul>
<?php
$args = array( 'numberposts' => 1000 );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>

3. Create the Page

After that all you have to do is to create a page inside WordPress and make it use the “Archives” template. That’s it.

I am using that code on my archives page right now. The only thing I am not happy with is the fact that all links are mixed together. I would like to separate them month by month, to make it easier for humans to find what they are looking for.

As soon as I solve that problem I’ll post an update, so stay tuned.

Wanna make money with your website?


Original Post: Building an “Archives” Page with Simple PHP