Wordpress - static content on front page
Wednesday, May 30th, 2007
This is a follow on from my other post on adding static content for search engines :
This is really useful if you want static content on the front page, but you want to run blog posts below the content.
I have had sooo many problems with this. I have tried ‘sticky posts‘ and a number of other plugins to get s ingle static piece of content to just sit there without affecting other parts of the site ( i wont extrapolate, aside that this issue is a pain)
The usual route is to set up an include on the theme above the blog posts. the downer is that this include then repeats itself on the ‘previous articles’ pages and so you get duplicate content…. not good for seo
So here is my fix
I have added this code below
<?php get_header(); ?>
<?php get_sidebar(); ?>
and ive made sure it’s within the div tags theming the content.
<?php if ( $paged < 2 ) { // Do stuff specific to first page?>
<?php if ( is_home() ) : ?>
<div id=”category-description”>
<?php echo get_staticpage(); ?>
</div>
<?php endif; ?>
<?php } else { // Do stuff specific to non-first page ?>
<?php } ?>
I have then set up a page called static-content.php and added the relevant content and saved it within the template files.
and then i have edited :
and function get_staticpage() {
do_action( ‘get_staticpage’ );
if ( file_exists( TEMPLATEPATH . ‘/staticpage.php’) )
load_template( TEMPLATEPATH . ‘/staticpage.php’);
else
load_template( ABSPATH . ‘wp-content/themes/default/staticpage.php’);
}
then i have edited :
wp-includes/general-template.php
and added at the top of the file (below the php tag) :
function get_staticpage() {
do_action( ‘get_staticpage’ );
if ( file_exists( TEMPLATEPATH . ‘/staticpage.php’) )
load_template( TEMPLATEPATH . ‘/staticpage.php’);
else
load_template( ABSPATH . ‘wp-content/themes/default/staticpage.php’);
}
I’ve been reading up on my SEO (it’s always good to get back to grass roots) Ive been reading Aaron Wall’s
Ive been looking for a way of adding a piece of static content at the top of each category in a wordpress archive. The problem with wordpress is that there is too much content curn on any given category page, so as a result the search engines don’t know what content to hang from when it comes to keywords. Its been a pain in the ass finding a decent solution this, so im sharing with you now !