2022年10月06日
ワードプレスのデータベース構造
wp_posts CREATE TABLE `wp_posts` ( `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `post_author` bigint(20) unsigned NOT NULL DEFAULT '0', `post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_content` longtext COLLATE utf8mb4_unicode_520_ci NOT NULL, `post_title` text COLLATE utf8mb4_unicode_520_ci NOT NULL, `post_excerpt` text COLLATE utf8mb4_unicode_520_ci NOT NULL, `post_status` varchar(20) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT 'publish', `comment_status` varchar(20) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT 'open', `ping_status` varchar(20) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT 'open', `post_password` varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '', `post_name` varchar(200) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '', `to_ping` text COLLATE utf8mb4_unicode_520_ci NOT NULL, `pinged` text COLLATE utf8mb4_unicode_520_ci NOT NULL, `post_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_modified_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `post_content_filtered` longtext COLLATE utf8mb4_unicode_520_ci NOT NULL, `post_parent` bigint(20) unsigned NOT NULL DEFAULT '0', `guid` varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '', `menu_order` int(11) NOT NULL DEFAULT '0', `post_type` varchar(20) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT 'post', `post_mime_type` varchar(100) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '', `comment_count` bigint(20) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`), KEY `post_name` (`post_name`(191)), KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`), KEY `post_parent` (`post_parent`), KEY `post_author` (`post_author`) ) ENGINE=InnoDB AUTO_INCREMENT=74 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci |wp_postmeta
CREATE TABLE `wp_postmeta` (
`meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`post_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`meta_key` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_520_ci,
PRIMARY KEY (`meta_id`),
KEY `post_id` (`post_id`),
KEY `meta_key` (`meta_key`(191))
) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci |
記事本体(wp_posts)
post_status → 公開(publish) 下書き(draft) ゴミ箱(trash)
post_date → 登録日
post_type → 投稿タイプ post とか
投稿者 muuming : 12:16
2022年03月19日
wp フック順番
https://wemo.tech/2062
after_setup_theme
set_current_user
registered_post_type(複数回実行)
registered_taxonomy(複数回実行)
init
customize_register(カスタマイザープレビュー時のみ)
wp_loaded
parse_request
send_headers
parse_query(クエリの呼び出しによって複数回実行される。フロント側で最速のタイミングはこの辺だった。)
pre_get_posts(クエリの呼び出しによって複数回実行される。フロント側で最速のタイミングはこの辺だった。)
the_posts
wp
admin_bar_init
template_redirect
wp_enqueue_scripts
wp_print_scripts
wp_head
wp_footer
shutdown
投稿者 muuming : 07:24
2020年12月15日
uploadディレクトリにFTPなどで置いたファイルを登録
$file = (wp_upload_dir())["basedir"]."/lps/sawara.jpg"; //データの登録 $attachment = array( 'post_mime_type' => mime_content_type($file), //1 'post_title' => sanitize_file_name(file), //2 'post_content' => '', //3 'post_status' => 'inherit' //4 ); $attach_id = wp_insert_attachment( $attachment, $file, 0 ); print $attach_id." としてアップ
"; //サムネイルやらその他情報の作成しそれを元にデータをアップデート $attach_data = wp_generate_attachment_metadata( $attach_id, $file ); wp_update_attachment_metadata( $attach_id, $attach_data );
投稿者 muuming : 08:00
2020年10月20日
wordpressのrest_apiでのログイン判定
if (! is_admin() )
では取れないっぽい。
wordpress rest api get current user あたりで検索
うまく動くものが出来たら追記する予定
投稿者 muuming : 14:26
2020年10月10日
ワードプレスのアイコンフォント
管理画面のアイコンってFont Awesome的なものだよなとおもってたが dashicons ていうらしい
一覧を紹介しているいいページがまだ見つかってないのでそれは必要な時探す。
とりあえず使い方は このあたり
css
font-family: "dashicons";
content: "\f127";
cssfileの読み込み
wp_enqueue_style('dashicons', get_stylesheet_uri(), array('dashicons'));
通常は管理画面では読み込まれてるだろうからcssだけかな
投稿者 muuming : 15:34
2020年10月06日
ワードプレスでのデータベース操作方法
https://one-ap-engineer.com/wpdb/
この図はわかりやすい!
投稿者 muuming : 13:54
2020年10月05日
ワードプレス 有効・無効・アンインスコ時の処理をつける
https://blog.it.churaumi.tv/wordpress-plugin-register-activation-deactivation-uninstall-hook
/* 有効にした時に引数で指定したファンクションを実行 */