Word Press ログイン画面のラベルを変更する

Filed under: functions.php,wordpress — kdcs @ 22年8月15日 月曜日

ログイン時の「ユーザー名またはメールアドレス」のラベルを書き換える

例:メールアドレスだけにする

function change_loginpage_username_label($label){
if (in_array($GLOBALS['pagenow'], array('wp-login.php'))) {
if ($label == 'ユーザー名またはメールアドレス') { 
$label = 'メールアドレス';
}
}
return $label;
}
add_filter( 'gettext', 'change_loginpage_username_label' );

WordPress 自動更新の停止

Filed under: wordpress — kdcs @ 22年8月14日 日曜日

wp-config.phpのデバッグ設定の直下に記述

WordPressのすべての自動更新を停止する(プラグインやテーマ更新を含む)

define( 'AUTOMATIC_UPDATER_DISABLED', true );

メジャーアップデートの自動更新のみ停止する(マイナーは自動更新する)

define( 'WP_AUTO_UPDATE_CORE', minor );

WordPress ユーザープロフィール・一覧の姓名入れ替え

Filed under: functions.php,wordpress — kdcs @ 22年7月28日 木曜日

デフォルトではユーザープロフィール・一覧とも名姓の順なので、これを姓名の順に入れ替える

function.phpに記述

/* ---------------------------------------------------------------------------------------
   ◆◆◆ ユーザープロフィール・一覧 姓名入れ替え #########################################
------------------------------------------------------------------------------------------*/
// ユーザープロフィールの姓名入れ替え-----------------------------------------------------
function lastfirst_name() {
	?><script>
		jQuery(function($){
			$('#last_name').closest('tr').after($('#first_name').closest('tr'));
		});
	</script><?php
}
add_action( 'admin_footer-user-new.php', 'lastfirst_name' );
add_action( 'admin_footer-user-edit.php', 'lastfirst_name' );
add_action( 'admin_footer-profile.php', 'lastfirst_name' );
// ユーザー一覧の姓名入れ替え-------------------------------------------------------------
function lastfirst_users_column( $columns ) {
	$new_columns = array();
	foreach ( $columns as $k => $v ) {
		if ( 'name' == $k ) $new_columns['lastfirst_name'] = $v;
		else $new_columns[$k] = $v;
	}
	return $new_columns;
}
add_filter( 'manage_users_columns', 'lastfirst_users_column' );

function lastfirst_users_custom_column( $output, $column_name, $user_id ) {
	if ( 'lastfirst_name' == $column_name ) {
		$user = get_userdata($user_id);
		return $user->last_name . ' ' . $user->first_name;
	}
}
add_filter( 'manage_users_custom_column', 'lastfirst_users_custom_column', 10, 3 );

WordPress 5.5から実装された「勝手に生成されるwp-sitemap.xml」の対処法

Filed under: .htaccess,functions.php,wordpress,WP迷惑機能 — kdcs @ 22年7月20日 水曜日

WordPress5.5から自動的にサイトマップが生成されるようになり迷惑。
wp-sitemap.xmlを無効化する方法とリダイレクトさせる方法

function.phpに記述
こちらを記述するとwp-sitemap.xmlが404エラーになる

add_filter( 'wp_sitemaps_enabled', '__return_false' );

完全にサイトマップ機能を無効化したい場合はこちらも記述
※2022.7.20現在 未検証

remove_action( 'init', 'wp_sitemaps_get_server' );

既存のサイトマップ(Googleに検出させたいサイトマップ)にリダイレクトさせる
/wp-sitemap.xml → /sitemap.xml

.htaccessに記述

Redirect 301 /wp-sitemap.xml https://example.com/sitemap.xml

WordPress ログイン画面のプライバシーポリシーへのリンクを非表示にする

Filed under: functions.php,wordpress — kdcs @ 22年7月19日 火曜日

WordPressのバージョン たぶん5.9以降

function.phpに記述

//ログイン画面の言語切り替えを非表示にする------------------------------------------------
function delete_privacy_policy_loginpage( $link, $privacy_policy_url ) {
    if ( 'wp-login.php' === $GLOBALS['pagenow'] ) {
        return null;
    }
}
add_filter( 'the_privacy_policy_link', 'delete_privacy_policy_loginpage', 10, 2 );

サイト内検索

カテゴリー

最近の投稿

↑上に戻る