是否有插件或黑客插件,以便我可以在我自己的WordPress博客上进行类似Twitter的简短更新?

也许使用自定义帖子类型或这些行上的其他内容?

我要实现的是创建与博客上常规帖子不同的简短(150个字符限制)帖子。这些简短的更新发布后,我希望它们出现在主页上的自定义DIV标签中。

简而言之,与Twitter相同的功能,但仅在您的博客上。

谢谢

有帮助吗?

解决方案

如果您只想为摘录添加角色计数器,请使用此功能和JS。

函数的php.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' );

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 );
    } );
} );

循环

然后,在发布“ Twitter”之类的“ twitter”时,只需使用帖子格式“状态”(或其他任何内容),然后将以下内容放置在您的循环中:

// 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
}

其他提示

WordPress现在具有称为的帖子格式 status 这旨在用于简短状态更新。

您可以看到有关如何使用这些标准邮政格式的大量信息 邮政格式的法典页面

许可以下: CC-BY-SA归因
scroll top