WordPress Expert » Tutorials http://johnlamansky.com/wordpress Wed, 01 Jun 2011 18:58:49 +0000 en hourly 1 http://wordpress.org/?v=3.3 How to Remove Dates from WordPress Posts http://johnlamansky.com/wordpress/remove-post-dates/?utm_source=rss&utm_medium=rss&utm_campaign=remove-post-dates http://johnlamansky.com/wordpress/remove-post-dates/#comments Wed, 01 Jun 2011 17:27:56 +0000 John Lamansky http://johnlamansky.com/wordpress/?p=132 If your content is not time-oriented (such as when using WordPress in non-blog contexts), you may wish to remove the publication date from your posts since this information is not relevant and can give the impression that your older content is outdated.

1. The Manual Method

The “proper” way to do this would be to edit your theme and remove the code that displays the post dates.

  1. Backup your theme, just in case
  2. Go to “Appearance > Editor” and repeat the following steps for each of your theme’s PHP files
  3. Look for these function calls in your theme’s code: the_date(), echo get_the_date(), the_modified_date(), and the_time()
  4. Surround the function calls with PHP comment markers (/* and */); here are some examples:
    <?php /*the_date();*/ ?>
    <?php /*the_date('F j, Y');*/ ?>
    <?php /*echo get_the_date();*/ ?>
    <?php /*the_modified_date();*/ ?>
    <?php /*the_modified_date('', 'Last modified ');*/ ?>
    <?php /*the_time( get_option('date_format') );*/ ?>
  5. You may want to remove other text surrounding the function call. For example, if your theme has this code…
    <div>Published on <?php the_time( get_option('date_format') ); ?></div>

    …and you replace it with this…

    <div>Published on <?php /*the_time( get_option('date_format') );*/ ?></div>

    …your theme will output “Published on,” but not the date. Deleting “Published on” from your theme file will remove it from your site. Just be aware that you may have to remove text like this from your theme files to get a clean-looking result.

  6. Click “Update File”

2. The Automatic Method

If you’re looking for a quick fix, just go to “Appearance > Editor” in your WordPress admin and add this code to the top of your theme’s functions.php file:

function jl_remove_post_dates() {
	add_filter('the_date', '__return_false');
	add_filter('the_time', '__return_false');
	add_filter('the_modified_date', '__return_false');
} add_action('loop_start', 'jl_remove_post_dates');

(Note: This method requires WordPress 3.0 or above)

Now check your site and verify that the post dates are gone. If they’re not, try replacing the code above with this more “aggressive” version:

function jl_remove_post_dates() {
	add_filter('the_date', '__return_false');
	add_filter('the_time', '__return_false');
	add_filter('the_modified_date', '__return_false');
	add_filter('get_the_date', '__return_false');
	add_filter('get_the_time', '__return_false');
	add_filter('get_the_modified_date', '__return_false');
} add_action('loop_start', 'jl_remove_post_dates');
]]>
http://johnlamansky.com/wordpress/remove-post-dates/feed/ 14
Tip for Plugin Developers: Inline Changelogs http://johnlamansky.com/wordpress/inline-changelogs/?utm_source=rss&utm_medium=rss&utm_campaign=inline-changelogs http://johnlamansky.com/wordpress/inline-changelogs/#comments Fri, 03 Jul 2009 16:51:12 +0000 John Lamansky http://wordpress.jdwebdev.com/?p=106 Recently, the Dev4Press and Weblog Tools Collection blogs made posts about integrating plugin changelogs into the Plugins dashboard. This functionality was something I was already doing in the SEO Ultimate plugin, so I thought I’d share my technique for doing this. (My method is different because it’s simpler and it integrates directly into WordPress’s update message.)

Here’s what an inline changelog looks like when implemented:

Example of inline changelog from SEO Ultimate

As you can see, a small notice like this helps users know at-a-glance what’s new in your plugin update.

Here’s the code you can incorporate into your plugin:

<?php
function my_plugin_update_info() {
	if ( $info = wp_remote_fopen("http://www.example.com/my-plugin-updates.txt") )
		echo '<br />' . strip_tags( $info, "<br><a><b><i><span>" );
}
add_action('in_plugin_update_message-'.plugin_basename(__FILE__), 'my_plugin_update_info');
?>

Of course, to keep plugin users happy, be sure that your inline changelogs are informative and unobtrusive. Happy coding!

(Plugin users, if you’d like to see this feature implemented in your favorite plugins, you could try sending the plugin author a link to this post! You could also check out the new Changelogger plugin.)

]]>
http://johnlamansky.com/wordpress/inline-changelogs/feed/ 5
How to Find and Fix 404 Errors http://johnlamansky.com/wordpress/404-errors/?utm_source=rss&utm_medium=rss&utm_campaign=404-errors http://johnlamansky.com/wordpress/404-errors/#comments Wed, 28 May 2008 14:00:25 +0000 John Lamansky http://wordpress.jdwebdev.com/?p=72 If you’ve changed post slugs, taxonomy slugs, or permalink structures, you likely created 404 pages (page-not-found URLs) along the way.

These 404 pages certainly aren’t helpful for visitors who stumble across them and can increase your bounce rate. It can be a particular problem if search engines, pingbacks, and/or internal and external links are sending traffic to the old URLs.

Here’s how to resolve the issue:

Stage 1: Identify 404 Problem Pages

  • If you’re registered with Google Webmaster Tools, you can view the list of 404 errors that the Googlebot has come across.

  • You can also use the 404 Notifier plugin, which can notify you via email or RSS feed whenever a 404 error is thrown.

Stage 2: Redirect

  • If the 404 errors are due to a change in permalink structure, upgrade to the latest version of WordPress. WordPress 2.3 and above will automatically redirect your old permalink structure to your new one.

  • If the 404s are because of changed slugs, or other, more complex content relocations, use the powerful Redirection plugin to point visitors and search engines to the right place with 301 redirects.

]]>
http://johnlamansky.com/wordpress/404-errors/feed/ 13
How to Backup Your WordPress Theme http://johnlamansky.com/wordpress/backup-theme/?utm_source=rss&utm_medium=rss&utm_campaign=backup-theme http://johnlamansky.com/wordpress/backup-theme/#comments Mon, 19 May 2008 19:41:51 +0000 John Lamansky http://wordpress.jdwebdev.com/?p=70 If you’re about to make a modification to your theme files that you aren’t sure about, it’s a good idea to backup your theme, especially if your theme is custom-made (i.e. you can’t just re-download it if something goes wrong), or if you have many other theme modifications you want to preserve.

Here are two ways to do it:

The Quick Method

You can easily backup a single theme file by going to “Appearance > Editor,” clicking the file, and then copying-and-pasting the contents of the theme file you’re editing into a Notepad document. Read more detailed steps here.

The Complete Method

These steps will help you backup your entire theme:

  1. Download an FTP program (such as FileZilla) if you don’t have one already.
  2. While you’re waiting for that, go to your WordPress admin, and then click on “Appearance.”
  3. Under the “Current Theme” header, note the file path that comes after “All of this theme’s files are located in.”
  4. Once your FTP program is downloaded, installed, and ready to go, connect to your website by entering in your FTP hostname, username, and password (these should be different from your WordPress username and password). If you don’t know what they are, ask your web host for help.
  5. Once you’ve connected to your website, browse to the folder that contains your WordPress installation (again, ask your web host if you need help finding it), and then browse to the folder you noted in step 3.
  6. Tell the FTP program to download the entire theme folder to a location on your computer.
  7. Once that’s done, check to make sure the FTP program says the files transferred correctly.
]]>
http://johnlamansky.com/wordpress/backup-theme/feed/ 9
How to Put Blog Posts in Their Own Subdirectory http://johnlamansky.com/wordpress/blog-subdirectory/?utm_source=rss&utm_medium=rss&utm_campaign=blog-subdirectory http://johnlamansky.com/wordpress/blog-subdirectory/#comments Wed, 07 May 2008 14:00:17 +0000 John Lamansky http://wordpress.jdwebdev.com/?p=59 Cool WordPress-as-a-CMS tip: If your WordPress-powered site includes a blog as a component, rather than the main function, you can opt to put blog posts and archives (category/tag/date/author) into their own subdirectory (such as “blog”).

As of this writing, I have this set up on my site; just go to one of my post pages or archives and then check out the address bar to see it in action.

Here’s how to do it:

First, login to your WordPress administration. Click “Settings” (or “Options”), then click “Permalinks.”

After the beginning slash in the “Custom Structure” box, add the subdirectory name followed by another slash.

For example, if your permalink structure was this:

/%year%/%monthnum%/%day%/%postname%/

…You would change it to this:

/blog/%year%/%monthnum%/%day%/%postname%/

Click the “Save Changes” button. Now your post and archive permalinks will contain the subdirectory name that you entered. Enjoy!

]]>
http://johnlamansky.com/wordpress/blog-subdirectory/feed/ 2
How to Create Spaced Lists in WordPress Posts http://johnlamansky.com/wordpress/spaced-lists/?utm_source=rss&utm_medium=rss&utm_campaign=spaced-lists http://johnlamansky.com/wordpress/spaced-lists/#comments Mon, 05 May 2008 14:00:33 +0000 John Lamansky http://wordpress.jdwebdev.com/?p=57 Say you have a list like this:

  • Item A
  • Item B
  • Item C

…And you want it to look like this:

  • Item A

  • Item B

  • Item C

When you have lists that contain a lot of text, spacing out the items can improve readability.

As far as I know, this isn’t possible in the visual editor (unless you went the semantically-incorrect route of creating a new <ul> for each list item).

To add spacing, you’ll need to go to the HTML editor. In WordPress 2.5, select the “HTML” tab of the post editor; in previous 2.x versions, select the “Code” tab.

Here is what your list code would look like:

<ul>
<li>Item A</li>
<li>Item B</li>
<li>Item C</li>
</ul>

To create spacing, just add the <p> and </p> tags to the beginning and end of each item like so:

<ul>
<li><p>Item A</p></li>
<li><p>Item B</p></li>
<li><p>Item C</p></li>
</ul>

Then save the post and voilĂ ! Spaced lists.

]]>
http://johnlamansky.com/wordpress/spaced-lists/feed/ 2
How to Optimize Your WordPress Database Tables http://johnlamansky.com/wordpress/optimize-database-tables/?utm_source=rss&utm_medium=rss&utm_campaign=optimize-database-tables http://johnlamansky.com/wordpress/optimize-database-tables/#comments Tue, 04 Mar 2008 14:21:49 +0000 John Lamansky http://wordpress.jdwebdev.com/blog/tutorials/optimize-database-tables/ As time goes on, all the database operations performed on your WordPress tables (which are what store your blog posts and other data) will create what’s called “overhead.” To keep your database running smoothly, you can get rid of this overhead by “optimizing” your tables (similar to defragmenting your hard drive).

Here are two ways to do it.

Method 1: WP-DBManager

Download and install the WP-DBManager plugin.

The plugin allows you to, among other things, optimize your tables from within your WordPress admin (just go to the “Databases” section and click the “Optimize DB” tab), as well as schedule table optimizations on a regular basis.

However, the plugin also lets you delete tables and provides an interface for running MySQL queries, so if you don’t like the idea of all that power being vested in your WordPress admin, you can try the phpMyAdmin method instead.

Method 2: phpMyAdmin

Here are the steps for using the phpMyAdmin software.

  1. Go to your web hosting account’s cPanel and click the “phpMyAdmin” icon. If you don’t see one, look for a “MySQL Databases” icon, click it, scroll to the bottom of the page, and click the “phpMyAdmin” link.

  2. Select your WordPress database.

  3. Look in the “Overhead” column. If you see a table with overhead, click the overhead value.

  4. Click the “Optimize Table” link.

  5. Once it’s done, click the Back button twice (to go back to the tables list), and repeat from step 3.

And that’s it!

]]>
http://johnlamansky.com/wordpress/optimize-database-tables/feed/ 13
How to Integrate Feedburner into WordPress http://johnlamansky.com/wordpress/setup-feedburner/?utm_source=rss&utm_medium=rss&utm_campaign=setup-feedburner http://johnlamansky.com/wordpress/setup-feedburner/#comments Mon, 03 Mar 2008 15:38:30 +0000 John Lamansky http://wordpress.jdwebdev.com/blog/tutorials/setup-feedburner/ Feedburner is a free, Google-owned service that provides great feed statistics and services to bloggers and other feed publishers.

Here’s how to integrate Feedburner with a self-hosted WordPress blog:

  1. Sign up — First of all, you’ll need to sign up for a Feedburner feed if you haven’t already.

  2. MyBrand (optional) — This isn’t required, but I recommend activating Feedburner’s MyBrand service so that your feed is accessed through your own domain name instead of feedburner.com. This will make it so much easier to keep your subscribers if you decide you want to stop using Feedburner sometime in the future.

    To activate the service, click the “My Account” link at the top-left-hand-corner of the Feedburner website, and then click “MyBrand” in the sidebar navigation menu. Follow the instructions, and click “Activate.” (If you aren’t sure how to add the CNAME entry, ask your web host for assistance.)

  3. FeedSmith — Next you’ll need to install a WordPress plugin: the FeedSmith plugin from Feedburner. Here are the steps:

    1. Download Feedburner’s FeedSmith plugin
    2. Use an FTP program to upload FeedBurner_FeedSmith_Plugin.php to your wp-content/plugins/ directory.
    3. Login to your WordPress admin and go to the Plugins section. Click “Activate” in the “Feedburner FeedSmith” row.
    4. Go to Settings > FeedBurner in your WordPress admin and follow the step-by-step instructions. Click Save when you’re done.
  4. Feedburner Email Subscription (optional) — While you’re at it, it’s also a great idea to give your users the option of email-based blog subscription!

And that’s it! Thanks to the FeedSmith plugin, visitors will now be automatically redirected to your Feedburner feed when they subscribe. Enjoy your Feedburner stats and features!

]]>
http://johnlamansky.com/wordpress/setup-feedburner/feed/ 10
Enable Email Subscription with Feedburner http://johnlamansky.com/wordpress/feedburner-email/?utm_source=rss&utm_medium=rss&utm_campaign=feedburner-email http://johnlamansky.com/wordpress/feedburner-email/#comments Tue, 26 Feb 2008 15:00:58 +0000 John Lamansky http://wordpress.jdwebdev.com/blog/tutorials/feedburner-email/ Not all visitors to your WordPress blog will be familiar with RSS feeds or how they work, while some other visitors just don’t want to mess with using a feed reader. RSS isn’t the only push-delivery method out there: email subscription is another great service to offer to your visitors.

First you’ll need an email subscription service that’ll send out the emails for you. The service I recommend is Feedburner. Check out my email subscription form in the sidebar to see how it looks and works.

First setup a Feedburner feed if you don’t have one already. Then follow these steps:

  1. Go to Feedburner.com and login
  2. Click “My Feeds” in the upper-left-hand corner
  3. Select your feed from the list
  4. Click the “Publicize” tab
  5. Click “Email Subscriptions” on the left
  6. Make sure “Feedburner” is selected, and click “Activate”
  7. Copy the HTML code in the box
  8. Login to your WordPress blog’s administration area
  9. Go to the “Appearance” section (a.k.a. “Design,” “Presentation,” or “Themes” in versions prior to 2.7)
  10. If you’re using Widgets in your sidebar, click the “Widgets” sub-tab. Add a “Text” widget to the sidebar you want, and paste the HTML code in the configuration section. Save your changes, and that’s it!
  11. If you’re not using widgets, you’ll need to have basic knowledge of HTML. First click the “Editor” or “Theme Editor” subpanel, and select “Sidebar” from the list. Usually sidebar modules go between <li></li> tags; some other themes use <div>. Paste the code in your sidebar between the appropriate set of tags in the location you want, click Save, and you’re done!
]]>
http://johnlamansky.com/wordpress/feedburner-email/feed/ 92
The Difference Between Trackbacks and Pingbacks http://johnlamansky.com/wordpress/difference-between-trackbacks-and-pingbacks/?utm_source=rss&utm_medium=rss&utm_campaign=difference-between-trackbacks-and-pingbacks http://johnlamansky.com/wordpress/difference-between-trackbacks-and-pingbacks/#comments Thu, 07 Feb 2008 15:00:34 +0000 John Lamansky http://wordpress.jdwebdev.com/blog/tutorials/difference-between-trackbacks-and-pingbacks/ Ever wondered what the difference is between a trackback and a pingback? They both let you know when someone else has blogged about one of your posts, and the terms seem to be used interchangeably at times — so what’s the deal?

The WordPress Codex’s Introduction to Blogging article has a good explanation:


Trackbacks were originally developed by SixApart, creators of the MovableType blog package. [...] Most trackbacks send to Person A only a small portion (called an “excerpt”) of what Person B had to say. This is meant to act as a “teaser”, letting Person A (and his readers) see some of what Person B had to say, and encouraging them all to click over to Person B’s site to read the rest (and possibly comment).

[...]

Pingbacks were designed to solve some of the problems that people saw with trackbacks. There are three significant differences between pingbacks and trackbacks, though.

  1. Pingbacks and trackbacks use drastically different communication technologies (XML-RPC and HTTP POST, respectively).
  2. Pingbacks support auto-discovery where the software automatically finds out the links in a post, and automatically tries to pingback those URLs, while trackbacks must be done manually by entering the trackback URL that the trackback should be sent to.
  3. Pingbacks do not send any content.

So there you have it: pingbacks can be automated and don’t send content, whereas trackbacks are manual and send an excerpt of the initiating post.

]]>
http://johnlamansky.com/wordpress/difference-between-trackbacks-and-pingbacks/feed/ 3