3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WordPress Jetpackのパプリサイズ共有で常にハッシュタグなどを付けたい

Last updated at Posted at 2016-06-28

Jetpackの仕様

  • 投稿編集画面にある「カスタムメッセージ」に入るのは基本的にタイトル
  • 配信時にURLが追加される

改変したい部分の仕様

  • タイトル前に特定の文言(e.g. [更新しました])
  • ハッシュタグもつける(e.g. #mynews)

要は毎回の手入力が面倒。

ソース

元ネタはこちら
https://wordpress.org/support/topic/wpas_default_message-filter-not-working

実行順の問題で「プラグイン」にしないといけません。
テーマの functions.php に記述する方法は不可。
プラグインのヘッダー情報とかは以下参照。
https://developer.wordpress.org/plugins/the-basics/header-requirements/

my-jetpack-publicize-message.php
<?php
/*
Plugin Name: My Jetpack Publicize Message
Plugin URI: 
Description: 
Version:     0.1.0
Author:      Your Name
Author URI:  
License:     GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Domain Path: /languages
Text Domain: my-jpm
*/

/**
 * The message prepended to the Publicize custom message.
 *
 * @module publicize
 *
 * @since 2.0.0
 *
 * @param string $prefix String appended to the Publicize custom message.
 */
function my_wpas_default_prefix( $prefix ) {
	$default_prefix = '[update] ';
	return $prefix;
}
add_filter( 'wpas_default_prefix', 'my_wpas_default_prefix' );

/**
 * The message appended to the Publicize custom message.
 *
 * @module publicize
 *
 * @since 2.0.0
 *
 * @param string $suffix String appended to the Publicize custom message.
 */
function my_wpas_default_suffix( $suffix ) {
	return ' #mynews';
}
add_filter( 'wpas_default_suffix', 'my_wpas_default_suffix' );
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?