1
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にオリジナルデータをデータベースに入力する方法

Last updated at Posted at 2020-01-09

【このページは未完成です】

WordPressは記事としてデータ入力をしていますが、ショップデータのような場合データ入力したい場合があると思います。

ショップ名:**********
住所:***************
電話番号:*************
ホームページ:***************
価格:*************
特徴:****************

いわゆるデータベースとして保存することです。
こうやって保存することで、可能性や作業効率が一気にアップします。

WordPressにオリジナルデータを入力したいと考えたときに2つの方法があります。

1つ目は「カスタム投稿タイプ+カスタムフィールド」を使って入力する方法
こちらの方法は、初心者におススメです。

プラグインを組み合わせることで比較的に利用が可能になります。
有名なのが「カスタム投稿タイプ:Custom Post Type UI」と「カスタムフィールド:Advanced Custom Fields」です。

2つ目は「自作のテーブルをデータベース(通常はMYSQL)に作成する方法

自作プラグイン:https://www.webopixel.net/wordpress/637.html

管理画面にオリジナル設定ページを追加:https://h2ham.net/wordpress-creating-options-pages

Wordpressの管理画面からfuncitons.phpを開く

外観-テーマエディタ-funcitons.php

image.png

funcitons.phpに投稿タイプを追加する

functions.php
register_post_type('goods',array(
   'label' => '商品',
   'public' => true,
   'show_ui' => true,
));

image.png

タクソノミー(分類)の追加

functions.php
register_taxonomy('goods_category','goods',array(
   'label' => 'カテゴリー',
   'show_ui' => true,
   'hierarchical'=> 'true',
));

1
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
1
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?