AffiloBlueprint:
Using Posts in Wordpress Theme Instead of Pages
May 12th 2009 09:09 pm
I’m taking a little side trip in my review of AffiloBlueprint to post the exact steps I did to modify the Wordpress theme that comes with it so that I could make my content into posts instead of pages.
This probably won’t mean much to someone who doesn’t have AffiloBlueprint, but basically it came with a WordPress theme that was built by them and assumes all of your content will be individual pages. It automatically adds any page title to the sidebar menu.
I wanted my content to be posts instead because then the web will be pinged when I update instead of me having to depend on search engine bots finding me.
But I also want one of my posts to be the homepage. (In Wordpress, you can set an individual page to be your homepage, but not an individual post).
To do it I created a new category called Home and then I changed some of the theme pages so that whatever post is in that category will be put on the home page. I thought this might be a clean way to do it.
One slight glitch though is that if you click on that home post in the sidebar, it takes you to the post page instead of the home page. It’s the same content, of course, but the url is different. But I’m not going to worry about that right now.
Also I’ve read that search engines don’t like it when you write a lot of posts in the same day; they start to see you as a possible spammer. I’m being careful to only post a new article once a day.
So here are the steps:
A couple of things to note about this method:
This probably won’t mean much to someone who doesn’t have AffiloBlueprint, but basically it came with a WordPress theme that was built by them and assumes all of your content will be individual pages. It automatically adds any page title to the sidebar menu.
I wanted my content to be posts instead because then the web will be pinged when I update instead of me having to depend on search engine bots finding me.
But I also want one of my posts to be the homepage. (In Wordpress, you can set an individual page to be your homepage, but not an individual post).
To do it I created a new category called Home and then I changed some of the theme pages so that whatever post is in that category will be put on the home page. I thought this might be a clean way to do it.
One slight glitch though is that if you click on that home post in the sidebar, it takes you to the post page instead of the home page. It’s the same content, of course, but the url is different. But I’m not going to worry about that right now.
Also I’ve read that search engines don’t like it when you write a lot of posts in the same day; they start to see you as a possible spammer. I’m being careful to only post a new article once a day.
So here are the steps:
- Install the plug-in Smart Update Pinger. This plug-in makes sure that a ping only happens when you first publish your post, not every time you update it. For now, disable pinging until you have everything set up (uncheck Enable Pinging in the settings). I also changed the pinging services to be these (source: Wordpress All Inclusive Ping List):
http://rpc.pingomatic.com
http://www.blogpeople.net/servlet/weblogUpdates
http://ping.myblog.jp
http://ping.bloggers.jp/rpc/
http://bblog.com/ping.php
- The smart update pinger wants there to be a file in wp-content called smart-update-pinger.log so just create a blank file and put it there.
- I didn’t want to mess up the theme so I copied the entire theme folder to a new folder called affiloblueprint_theme_1.0_customized and set that to be my default.
- Add this line to header.php:
<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom 0.3" href="<?php bloginfo('atom_url'); ?>" /> - Copy the contents of pages.php. Edit single.php and replace its contents with what you copied.
- Since the theme did not come with a 404 page, it means that if anyone looks for a page that you don’t have, they’ll see the default which is all your posts listed. Ugly. So save the contents of pages.php that you still have copied from the previous step and put it into a new file called 404.php. Edit this file. You want to take out anything that references a post. If it is a php if or while statement, you need to remove the matching end if or end while. Then put in appropriate text. My 404.php page now looks like this:
<?php get_header(); ?> <? global $options; foreach ($options as $value) { if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }}?> <div id="content" class="normal"> <div class="post"> <h1>Page not Found</h1> <div class="entry"> You seem to be looking for a missing page.<br /><br /> Try checking the menu on the left side. </div> </div> <?php get_sidebar(); ?> </div> <?php get_footer(); ?>
- Add a category called home. For the category slug, put your website name. Make a note of the id (hover over it and look at your status bar).
- Whatever post you want to be on your home page, assign it the home category. Note: If you’ve installed the All-in-one-SEO plug-in as instructed in the video, keep in mind that the meta title, keywords, and description on the home page come from the All-in-one-SEO settings page, not from the post you’re using on your home page. Also don’t forget to change the Post Title Format to %post_title%.
- In Settings/Reading make sure Front Page Displays As is set to Your Posts. (Note: if you don’t see this, your version of Wordpress doesn’t have it. Consider upgrading.)
- Edit sidebar.php. Right after the line with ul class=”items” near the bottom, delete or comment out this line:
<?php wp_list_pages('title_li=&sort_column=menu_order&exclude='.get_option('ddm_page_hide')); ?>
- Still in sidebar.php, at the place where you deleted the previous line, add this:
Note: You can tweak the arguments in the get_posts function. I put order=asc so that my posts will show in chronological order. Also if you leave numberposts out, it uses the default of only showing 5 posts, but -1 means there’s no limit. See http://codex.wordpress.org/Template_Tags/get_posts for more info.
<?php $posts=get_posts('numberposts=-1&order=ASC'); if ($posts) { foreach($posts as $post) { setup_postdata($post); ?> <li class="page_item page-item-3 current_page_item"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li> <?php } } ?>
- Note: at the time of this writing, there is an error in sidebar.php that causes it not to validate. Look for the second ul tag. If there isn’t a li tag preceding it, add it. So in other words, change this:
to this for the SECOND ul tag:
<ul class="items">
Also add a closing li to the closing ul of the inner one. So change this:<li><ul class="items">
to this for the FIRST closing ul tag:</ul>
(I’ve emailed Affilorama support about this, so hopefully they’ll correct it in the future).</ul></li>
- Save page.php as home.php. Delete the following lines:
Starting with and including this line:through and including this line:<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Where you deleted those lines, put the following but replace the category number 3 with the id number of the home category you added above.<?php endwhile; endif; ?>
<?php $temp_query = $wp_query; ?> <?php query_posts('cat=3'); ?> <?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h1><?php the_title(); ?></h1> <?php the_content(); ?> </div> <?php endwhile; ?>
- Double check that your site looks the way you want it; the title of your post shows in the sidebar. Also it wouldn’t hurt to run it through an html validator. Just click on that link, copy/paste your url into the tool, and click on Check. If the result shows as green, your html is valid. If it doesn’t, you have some errors to fix. Note: if you’ve copied the code from one of Mark’s review table pages, you’ll have some things to clean up. He used some things that are the wrong syntax like ‘baseline’ instead of ‘bottom’.
- A word about readable human sitemaps for your website. I wanted one that would let me exclude certain pages because later I’ll be doing my PPC landing pages as pages instead of posts. This way they won’t show up in my sidebar. I also don’t want them in my sitemap but I do want my privacy policy, which is also a page.
I downloaded and tested every one in the Wordpress plugin directory, but not a single one would let me do this. They either don’t show pages to start with, or they let me exclude all pages but not certain pages.
So my compromise is that I’m not including any pages in my sitemap.
If you want to do the same (list only posts) and you only want the link to the post to show, then I recommend you download WP Simple Sitemap. Just follow the installation instructions and you’re done.
However, I decided to use PS Auto Sitemap because a) it looks nicer (it has templates you can choose from to control the look) and b) it lists the categories. (If you want to see what it looks like, you can check out my site map).
One downside is that the categories are links. I definitely don’t want this because it defeats the purpose of having each post look like a page. So I recommend doing this to keep the category headings but not have them be links to category pages:- Make a copy of the original ps_auto_sitemap.php and delete the following **make sure you leave the single quote at the end:
Also delete its matching end tag **make sure you get the dot and both single quotes:<a href="' . get_category_link( $cat_id ). '" title="' . get_the_category_by_ID( $cat_id ) . '">
And then delete this **make sure you leave the single quote at the end:. '</a>'
and its ending dot and end tag:<a href="' . get_category_link( $category->term_id ). '" title="' . attribute_escape( $category->name ) . '">
. '</a>'
- Replace the live ps_auto_sitemap.php with your changed one. Note that it won’t show you an updated page, even if you clear your cache and refresh, unless it thinks you made changes. So go into settings and save a change. Then change it back and save again. This should goose it into showing your changed format for the page.
- Also in settings, uncheck Display Page Tree.
- Make a copy of the original ps_auto_sitemap.php and delete the following **make sure you leave the single quote at the end:
- Go back into the settings for Smart Update Pinger. Check Enable Pinging and click on Ping Services Now (you only have to do this for the first time; after that it will ping automatically when you create new posts).
- Here’s how to solve the problem of your home page showing with the url of your post: add a redirect to your .htaccess file.
So let’s say your home post url is: www.yourdomain/some-post.php
Add this line to your .htaccess file:
redirect 301 /some-post.php http://www.yourdomain.com
This way every time someone clicks on a link to the post from within your site, they will be redirected to your home page, which is really the post.
A couple of things to note about this method:
- I haven’t had a need to implement siloing that Mark talks about. My guess is that the template would have to be tweaked further to implement it since now it shows posts instead of pages.
- One good benefit about this method is since the sidebar only shows posts, if you create your PPC pages as PAGES instead of POSTS, they will automatically be excluded from the sidebar without you having to do anything further.
Max responded on 12 Jul 2009 at 3:28 am #
Good day! While this information may be a little dated, I’ve found that Smart Update Pinger is no longer updated for use with wordpress 2.1 and above.
Check out this article for more information about this:
http://www.maxblogpress.com/blog/211/important-message-smart-update-pinger/
You can use the MaxBlogPress Ping Optimizer as a replacement for the Smart Update Pinger
susb8383 responded on 12 Jul 2009 at 11:03 pm #
Hi Max,
Thanks for the info.
Even though the SmartUpdatePinger may not be maintained anymore, that doesn’t mean it isn’t working. If the newer versions of Wordpress don’t have anything in conflict, it will still work.
I’m using it with Wordpress 2.7.1 and it works fine. When I created a new post, the log tells me the ping happened, but when I edit an existing post, it tells me it didn’t ping because it was just an update.
In the future, there may be a version it breaks with, but so far 2.7.1 works fine.