Archive for the ‘how to’ Category
How to create a list of posts by category in WordPress
I have to say creating a link lists of posts by category in WordPress is downright painful. To create the archive list ( see link near search box on sidebar ) you need a list of your categories, the category number. You will use these to create an archives.php page.
1) A list of your categories can be found by going to the Dashboard, then drop down the Posts menu and select categories. These are the headings you put between the <br><h3>Category Name</h3> in the php below.
2) Category numbers had to be dug out of my database. I used MySQL Admin, went to my WordPress database. Select your database, find the wp_terms table and click on the leftmost icon under ‘Action’ to list your tags and categories. The link_id is the category number.
3) PHP code copy and paste this to a file named Archives.php. Change the category names and numbers to match those on your website. Also add or delete as many categories as you need. Your template is likely different than mine you may need to adjust the sidebar, footer etc to match your template’s style
4) showposts=200 is the maximum number of posts it will show in that category, adjust if you need to.
<?php
/*
Template Name: Archives
*/
?>
<?php get_header(); ?>
<div id=”content”>
<h2>Archives</h2>
<div>
<p>Complete archive of the blog’s posts sorted by category</p>
<br><h3>Fun things to do in Houston</h3>
<?php query_posts(‘cat=5&showposts=200′); ?>
<?php while (have_posts()): the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<?php endwhile; ?>
<br><h3>OMG We’re in Texas</h3>
<?php query_posts(‘cat=7&showposts=200′); ?>
<?php while (have_posts()): the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<?php endwhile; ?>
<br><h3>The Move</h3>
<?php query_posts(‘cat=15&showposts=200′); ?>
<?php while (have_posts()): the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<?php endwhile; ?>
<br><h3>This ‘n That</h3>
<?php query_posts(‘cat=14&showposts=200′); ?>
<?php while (have_posts()): the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<?php endwhile; ?>
<br><h3>Tokyo Trip</h3>
<?php query_posts(‘cat=172&showposts=200′); ?>
<?php while (have_posts()): the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<?php endwhile; ?>
<br><h3>Geekiness</h3>
<?php query_posts(‘cat=83&showposts=200′); ?>
<?php while (have_posts()): the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<?php endwhile; ?>
<br><h3>Photos</h3>
<?php query_posts(‘cat=10&showposts=200′); ?>
<?php while (have_posts()): the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<?php endwhile; ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
5) Upload your archives.php file to your theme directory on your webserver.
6) Finally create a new page – drop down the attributes menu on the right and select archives as your template
Or if you’d rather there’s a new plugin out to do display all posts in all categories for you James Wilkes Web Design
How to add an ‘email this’ link to your WordPress posts
I’ve noticed many of my website visitors come to my websites via links sent in emails. I thought I’d make it easier for visitors to email links by putting an ‘email this page’ link at the bottom of each post.
You’ll want to add this link to both the index.php and the single.php pages in your theme. Every theme is different so I can’t tell you exactly where to add it. I find the comments section in those pages and work my way up to where the date, tags or other miscellany is stored and added them there on my themes.
<a href=”mailto:?subject=<?php urlencode(the_title()) ?>&body=<?php urlencode(the_permalink()) ?>”>Email this page</a></p>
You might also check out James Wilkes Design version of the link He is pickier than I about the encoding.
How to add ‘Twitter This’ links to your WordPress Posts
Twitter seems to be the preferred social network now so I decided I needed some ‘Twitter This’ links on my WordPress Blogs.
You’ll want to add this link to both the index.php and the single.php pages in your theme. Every theme is different so I can’t tell you exactly where to add it. I find the comments section in those pages and work my way up to where the date, tags or other miscellany is stored and added them there on my themes.
The link you’ll want is:
<p><a href=”http://twitter.com/home?status=Reading:<?php echo urlencode(get_permalink(get_the_ID())); ?>&title=<?php echo urlencode(get_the_title(get_the_ID())); ?>”>Twitter this</a></p>
You might also check out James Wilkes Design version of the link He is pickier than I about the encoding.
Many thanks to:
Jamie Huskisson and to James Wilkes Design who gave me the pieces I needed to put the link together correctly.
Magazine style automatically updated WordPress blogs
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.

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.