0
0

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編集TIPS

Last updated at Posted at 2015-07-24

編集TIPS

WPのコピーサイトを作るときのTIPS

データベース上に散らばって入ってくるドメインの文字列を置き換える処理のひな型

sql
UPDATE wp_options SET option_value=REPLACE(option_value,"古いドメイン","新しいドメイン");
UPDATE wp_posts SET post_content=REPLACE(post_content,"古いドメイン","新しいドメイン");
UPDATE wp_posts SET guid=REPLACE(guid,"古いドメイン","新しいドメイン");
UPDATE wp_postmeta SET meta_value=REPLACE(meta_value,"古いドメイン","新しいドメイン");

【function.phpカスタマイズ】西暦4桁の年数から和暦の年数に変換

// 2015 -> H27など
WPのテーマ内、function.phpなどに記載して使おう。

functions.php
// 西暦から和暦に変換
function jp_wareki( $datenum ) {
	$y = substr( $datenum, 0, 4 );
	$m = substr( $datenum, 4, 2 );
	$d = substr( $datenum, 6, 2 );

	//if ( checkdate($m, $d, $y) ) {
		if ( $datenum >= 19890108 ) {
			$wname = "H";
			$y -= 1988;
		} elseif ( $datenum >= 19261225 ) {
			$wname = "S";
			$y -= 1925;
		} elseif ( $datenum >= 19120730 ) {
			$wname = "T";
			$y -= 1911;
		} elseif ( $datenum >= 18680125 ) {
			$wname = "M";
			$y -= 1867;
		}
		$datenum = $wname.(string)$y;
	//} else {
	//	$datenum = "日付が正しくありません。";
	//}

	return $datenum;
}

【プラグイン】Child Pages Shortcode

固定ページの親ページで子ページのサムネイルやexcerptを表示するプラグイン、ユーザーが触れる範囲でphpコードを埋め込んだりしたくない時(勝手にいじって壊される可能性があるなど)に利用すればいいかも

wp-blog-header.php が404エラーを返す場合

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?