Herself's Webtools

Scripts, HowTos, Templates, Plugins, Widgets, Tips and Useful Information

Archive for the ‘hack your template’ Category

Simple SEO hacks for WordPress

with 2 comments

Always there are trade offs. The more information you pull from your database to put in each page, the greater the drain on your server.

To do well in search engine rankings you want individual titles and meta descriptions for each individual page. To do this in WordPress you pull the information from the database in your header.php file.

When I ran into server problems I took this out and yes, it hurt my search engine rankings. Now that I’m with Media Temple and things seem to be running smooth I’m adding them back in.

Most, but not all, themes do have the title customized, few have meta tags customized and even fewer have them done properly.

To have an individual title for each separate post and page use this in place of the current title<title>…</title> in your header file.

<title><?php if (is_single() || is_page() || is_archive()) { wp_title(”,true); } else { bloginfo(‘name’); echo(‘ &#8212; ‘); bloginfo(‘description’); } ?></title>

To have a customized meta description for each page and post use this in your head.php file

<?php if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<meta name=”description” content=”<?php the_excerpt_rss(); ?>” />
<?php endwhile; endif; elseif(is_home()) : ?>
<meta name=”description” content=”<?php bloginfo(‘description’); ?>” />
<?php endif; ?>

I looked at several SEO optimized themes at WordPress and very few had the custom meta tags.

To see if the meta tag is working on your site pull up an individual post:

In your browser look for view->page->source

Look through the top of the page source and you should see <meta description and specific information for that page.

To see if the custom title is working bookmark the page and see if the title defaults to your blog name or the title of that page.

How do I know Google wants this.  Google told me.  Are you using Google Webmaster Tools?

And have you read Google Search Engine Optimization Guide ( pdf )?

Written by timestocome

November 22nd, 2009 at 11:49 am

Magazine style automatically updated WordPress blogs

without comments

I’ve been wanting a magazine style template for my main website splash page for about six months. And I’d been wondering how those scrapers, scraped you rss feed into their blog. Sometimes procrastination is a good thing when I finally got around to looking into it all I found most of the pieces had already been written.

blog-splash

Herself’s Green Things picks up the rss feeds from all my websites, turns them into blog posts and posts them in a magazine style theme all automatically.

I tried all the magazine themes I could find on the WordPress theme pages. The Magadine theme was the one that was most stable and easiest to hack so that’s the one I choose. Colors and fonts are very easy to change as are the number of columns and rows. ( change rows and columns in index.php )

<?php
if($count == 2 ) {
echo “<div style=’clear:both;’></div>”;
$count = 0;
}else{
$count += 1;
}
?>

count == 2 will give you 3 columns, count == 1 will give you two, count == 3 gives you four columns.

There are several WP plugins that will turn rss feeds into posts.  I chose Syndication which appears to have been pulled by the author because he/she didn’t want spammers using it.  That’s a shame, maybe if you ask nicely the coder will give you a copy, I’ll respect the coder’s wishes and not provide copies.  I like it best because it turns the title of the post into a link back to the original blog.

There are about a half dozen other choices available on the Wordpress plugins site.  Try them all see what suits you best. I thought WP-o-Matic and FeedWordPress also did excellent jobs.

After activating your syndication plugin you tell it which feeds to pull and all the ones I looked at gave you several options for credit, links how much of the feed entry to post ect.

Now you shouldn’t have to be told you should only be pulling your own content as I’m doing, or content from other blogs where you have permission.  It can be a great way to consolidate your blogs or promote other’s blogs.

You should also only use partial feeds to keep the search engine gods happy, and clicking on the title of the post should take your viewer to the original entry not wandering around the consolidated site.

One problem I had is that I couldn’t fetch 4 of my 13 feeds. I have no idea what or why so what I did was great a Yahoo Pipe of all my blog feeds, then have the syndication plugin grab that feed.

Written by timestocome

January 15th, 2009 at 5:00 am

How to add photos from Coppermine to any PHP page

without comments

Some asked how to add Coppermine photos to WordPress pages. This code will work for any page.

You need to replace MYSQL_SERVER with your database server, localhost usually works just fine.
USER_NAME is the user name for your Coppermine database
PASSWORD is the password for your Coppermine database
DATABASE_NAME is the name of your Coppermine database

Also replace YOUR_DOMAIN with the domain your Coppermine albums are hosted on. You might also need to change the path.

This code will give you a horizontal table of 3 thumbnail photos.


If you are using WordPress, you need to download any page from your theme. Change the file name to Coppermine and the Template name to Coppermine.

Remove the stuff in the middle. On my template that is everything between<div id=”content” class=”page”> and </div> but your template might be different.  The past this code into that section being sure to add your password, database etc.

When you are done, upload the new template to your theme directory.

Create a new page and choose Coppermine as the template.  All the work is done.  You can add text or anything else to the page.


<?php
if ( !($coppermine_db = mysql_connect( “MYSQL_SERVER”, “USER_NAME”, “PASSWORD” ))){
die ( “Can not connect to server” );
}else{
//select db
if ( !(mysql_select_db(“DATABASE_NAME”, $coppermine_db ))){
die ( “Can not select database” );
}
}

//ask mysql db for the path and file name of last five images uploaded
$coppermine_query = “select filepath, filename, ctime from cpg_pictures order by ctime desc limit 3;”;

$coppermine_result = mysql_query($coppermine_query);
$count = mysql_numrows( $coppermine_result );

//start link
$link =  “<center>”;

$link .= “<table border=3>”;
$link .=  “<th colspan=3><a href=\”http://YOUR_DOMAIN.com/coppermine/\”>Recent Photos</th><tr>”;
$i = 0;
while ( $i < $count ){

$path = mysql_result($coppermine_result, $i, “filepath” );
$name = mysql_result($coppermine_result, $i, “filename” );

$link .= “<td><img src=\”http://YOUR_DOMAIN.com/coppermine/albums/$path” . “thumb_$name\”></td>”;
$i++;
}

$link .= “</tr></table>”;
$link .= “</center>”;

//end link

//clean up
mysql_close();

print $link;

You can see an example of this code TimesToCome where I pull 3 photos from 3 different Coppermine albums onto the page.

Written by timestocome

September 22nd, 2008 at 4:24 pm