Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there a plugin or a hack such that I can make short updates similar to twitter's on my own wordpress blog?

Perhaps making use of a custom post type or something on those lines?

What i'm trying to achieve is to create short (150 character limit) posts different to the regular posts on the blog. Once these short updates are published, i'd like them to appear in a custom div tags on the home page.

In short, same functionality as twitter but just on your blog.

Thanks

share|improve this question
Edit.. Live Blogging is a plugin that came the closest, but instead of showing the updates in a post, i'd rather like to implement it directly in a theme. – Ron S May 10 '11 at 15:11
"but instead of showing the updates in a post, i'd rather like to implement it directly in a theme" ... what exactly does that mean? A post is always part of your theme. If you just want to style them differently, use post formats like @anu proposed. – kaiser May 10 '11 at 15:49

2 Answers

up vote 1 down vote accepted

If you just want to add a character counter for your excerpt, use this function and js.

The Php for your functions.php

// This goes in your functions.php file inside your themes folder

// Add theme support for post formats
add_theme_support( 'post-formats', array( 'aside', 'status' ) );

// Add the character counter to the admin UI
function wpse16854_char_count_script( $page ) 
{
  $post = get_post( $_GET['post'] );
  $post_type = $post->post_type;
  if ( 'page' !== $post_type )
    if ( 'post.php' === $page OR 'post-new.php' === $page )
      wp_enqueue_script( 'excerpt-counter', get_template_directory_uri().'/excerpt-counter.js', array('jquery') );
}
add_action( 'admin_enqueue_scripts', 'wpse16854_char_count_script' );

The JavaScript

// This should be saved inside a file named 'excerpt-counter.js' inside your themes folder
jQuery( document ).ready( function($)
{
    $( "#excerpt" ).after( "<p style=\"text-align:center;\"><small>Excerpt length: </small><input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"excerpt_counter\" readonly=\"\"> <small>character(s).</small></p>" );
    $( "#ilc_excerpt_counter" ).val( $("#excerpt").val().length );
    $( "#excerpt" ).keyup( function() 
    {
        $( "#ilc_excerpt_counter" ).val( $("#excerpt").val().length );
    } );
} );

The Loop

Then just use the post format "status" (or aside or whatever) when publishing a "twitter like" post and place the following inside your loop:

// place the following inside your loop
if ( has_post_format( 'status' ) OR 'status' == get_post_format( $GLOBALS['post']->ID ) OR is_object_in_term( $GLOBALS['post']->ID, 'post_format', 'status' ) )
{
    the_excerpt();
}
else 
{
    the_content(); // or however you want to treat normal posts
}
share|improve this answer
1  
Brilliant.. just enough ammo to get me started. Will post a complete update as soon as I get cracking with these. Thanks a ton kaiser!! – Ron S May 10 '11 at 16:11
Thank you. See Edit of the A - you need to also add theme support for post formats. – kaiser May 10 '11 at 16:22
Just some sidenotes: It's better to check the global $pagenow; or $typenow; to determine the admin page. Also, it's not really needed to check if the post format term is present. Alltogether: It's working, but it could be slightly easier be done. – kaiser Feb 20 '12 at 13:55

WordPress now has a post format called status which is meant to be used for short status updates.

You can see a lot of information about how to use these standard post formats in the Codex page on Post Formats

share|improve this answer
1  
"Status" is not a Post type, but rather a format of a Post post-type. – Chip Bennett May 10 '11 at 15:24
So based on the codex mentioned, I can tag a post to be a status and then call it into a theme? – Ron S May 10 '11 at 15:53
@Ron S - see my answer for further explanation and a little helper (character counter). – kaiser May 10 '11 at 16:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.