WordPress: Publishing posts in the past

There may be situations where you want to publish a post with a date in the past. On first sight WordPress does not have such a function. If you look closer you find on the page “Add new post” in the metabox “Publish” the following entry:

If you click on Edit a field appears in which you can enter the desired publishing date:

You can not only choose a date in the future but also a date in the past. After you have entered the date you should not forget to OK because otherwise the new date isn’t used when you publish the post:

If you press Publish the post will be published with the date set above:

Update: Monika Thon-Soun advised me that this practice may not be suitable if you’re focusing on search engine ranking since the subsequent entry may confuse Google et al.

WordPress: Shorten title

A frequently asked question in WordPress forum is how to shorten the title of a post to a predefined number of characters and to append a “…”.

The problem is solved with a few lines of code:

1
2
3
4
5
6
7
8
9
add_filter( 'the_title', 'short_title' );
function short_title( $title ) {
  $chars = 20;
  if ( strlen( $title ) > $chars ) {
    $title = substr( $title, 0, $chars );
    $title .= " …";
  }
  return $title;
}

The variable $chars has to be set to the number of characters you want to have in your title and in line 6 you have to define the text to replace the omitted part of the title (… is the typographically correct version of three points, called ellipse).

It’s a bit disadvantageous that the title could be cut in the middle of a word. If you like you can extend the function accordingly:

1
2
3
4
5
6
7
8
9
10
add_filter( 'the_title', 'short_title' );
function short_title( $title ) {
  $chars = 20;
  if ( strlen( $title ) > $chars ) {
    $title = substr( $title, 0, $chars );
    $title = substr($title, 0, strrpos( $title, ' ' ) );		    $title .= " …";
  }
  return $title;
}

If you copy the function into the file functions.php of your theme all calls of the_title will return the shortened title.

Remove “by author” post section from Genesis themes

As I already wrote in How-to remove the author from your Twenty-Ten posts most blogs do not need the section “by author” since there is only one author.
By default most Genesis themes contain this section (e.g. the prose theme):

Let’s see how-to remove the author’s name from the post info. Continue reading Remove “by author” post section from Genesis themes

WordPress: Remove links from the_category()

The standard way to display the categories a post belongs to is to use the function the_category, e.g, the call the_category(', '); will output:

link, photo, regular, video

As you see the categories are automatically linked to their respective category pages which in most cases is the style needed. Nevertheless there may be situations where you (or your customer) does not want the categories to link anywhere. Unfortunately WordPress does not provide any straightforward method to accomplish this so we have to make a small detour.

There are two ways we can take: rebuild the output or filter the output. Continue reading WordPress: Remove links from the_category()

Stop supporting commercial themes and plugins for free!

For the last days there has been much excitement about Thesis. Fo those who don’t know: Thesis is one of the more popular commercial themes for WordPress. Despite the special problems with this theme and its author it’s a more general question if customers of commercial should be supported for free by the community or not. So the question is:

Shall we stop supporting commercial
themes and plugins for free?

Pro:

  • The creator of commercial themes and plugins is making money from it and why should I give support? I will not get any money from my support but the creator will earn even more with subsequent products because of “the great support”.
  • People asking for support often are consultants, coders or designers making money from WordPress. They will not give me a single dollar if I give them support and help them to satisfy their customers.
  • There are special forums and mailinglist of commercial themes/plugins by the companies. Customers should use those.
  • I don’t support anything not GPL. Viva la revolución!
  • I could support the users but I would charge them for it.
  • There are better alternatives which are GPL. People should start using those and I’ll happily give them support.

Contra:

  • It’s all about the community! I don’t give a damn if others make money from it.
  • For me it doesn’t matter if I give support for free or commercial themes/plugins. The only reward I want is reputation.
  • Many of the commercial authors are active members of the WordPress community and give free support for other problems themselves.
  • Not all users (if not the majority) of commercial themes/plugins are professionals.
  • Often the commercial support is poor and the WordPress community should help those poor lost souls with their problems.
  • There are many support forums for other commercial software where people help each other in their spare time why should WordPress themes and plugins be an exception?
  • All this commercial stuff is making WordPress even more popular and so there will be more people helping WordPress getting better and better
  • Even Matt Mullenweg is profiting from all the free support from the community. Automattic would never be able to do it themselves and to present and enhance the best blogging system since sliced bread.

BTW: This is the third best article about this topic! (Couldn’t resist.)

Some links:

Updated pagebar v2.58

Some days I was happy that pagebar v2.57 does seem to work with the new WordPress v3.0 flawlessly but I laughed too soon. Mark (no link given) pointed out that custom taxonomies are disrupted when using pagebar v2.57.

The reason was some code I borrows from the “Multi Page Toolkit“:

add_action('init', 'pb_allpage_permalink', -1);
function pb_allpage_permalink() {
	global $wp_rewrite;
	$wp_rewrite->add_endpoint("all", EP_ALL);
	$wp_rewrite->flush_rules();
}

This code enables pagebar to display all parts of a page which is splitted into multiple parts. As you might see the code adds a new rule to the permalink structure. Unfortunately it corrupted the permalinks in a way that custom taxonomies stopped to worked.

The solution to this problem was to fire the action much, much later and to to update the rules transient (soft flush):

add_action('init', 'pb_allpage_permalink', 99);
function pb_allpage_permalink() {
	global $wp_rewrite;
	$wp_rewrite->add_endpoint("all", EP_ALL);
	$wp_rewrite->flush_rules(false);
}

Hopefully this will solve the problems with custom taxonomies completely.

Download: