WordPressで使っていたものが、EmDashでは何にあたるのかを表で引けるようにまとめました。テンプレートファイル、関数、管理画面、データベース、環境の順に並べています。
テンプレートファイル
WordPress | EmDash | 記事 |
|---|
front-page.php / home.php
| src/pages/index.astro
| くわしく |
single.php
| src/pages/posts/[slug].astro
| くわしく |
page.php
| src/pages/[slug].astro
| くわしく |
page-about.php
| src/pages/about.astro
| くわしく |
archive.php(投稿)
| src/pages/posts/index.astro
| くわしく |
category.php
| src/pages/category/[slug].astro
| くわしく |
tag.php
| src/pages/tag/[slug].astro
| くわしく |
search.php
| src/pages/search.astro(Blogテンプレート)
| くわしく |
404.php
| src/pages/404.astro
| くわしく |
date.php
| src/pages/archive/[month].astro(自分で作る)
| くわしく |
header.php / footer.php
| src/layouts/Base.astro
| くわしく |
sidebar.php
| ウィジェットエリア(<WidgetArea />) | くわしく |
template-parts/の中のファイル
| src/components/の中の.astroファイル
| くわしく |
archive-{投稿タイプ}.php
| src/pages/種類の名前/index.astro
| くわしく |
single-{投稿タイプ}.php
| src/pages/種類の名前/[slug].astro
| くわしく |
style.css
| 好きな場所に置いたCSSファイル | くわしく |
functions.php(設定)
| astro.config.mjs
| — |
functions.php(自作の関数)
| src/utils/の中の.tsファイル
| くわしく |
テンプレートタグ・関数
ページの骨組み
WordPress | EmDash | 記事 |
|---|
get_header() / get_footer()
| <Base>と</Base>で囲む
| くわしく |
get_template_part()
| importして<Card />のように書く
| くわしく |
wp_head() / wp_footer()
| <EmDashHead /> / <EmDashBodyEnd />(Base.astroに入っている)
| — |
register_post_type()
| seedのcollections、または管理画面の「コンテンツタイプ」 | くわしく |
wp_enqueue_style()
| import "../styles/〇〇.css";
| くわしく |
is_front_page() / is_page() / is_single()
| ファイルを分ける。共通パーツの中ではAstro.url.pathnameで判定する | くわしく |
register_taxonomy()
| seedのtaxonomies | くわしく |
get_template_directory_uri()
| publicの中は/から書く。srcの中はimportする
| くわしく |
bloginfo('name')
| getSiteSettings()で取った設定のtitle
| くわしく |
bloginfo('description')
| getSiteSettings()で取った設定のtagline
| くわしく |
記事を取る・出す
WordPress | EmDash | 記事 |
|---|
WP_Queryとループ
| getEmDashCollection()と.map()
| くわしく |
'orderby' => 'date'
| orderBy: { published_at: "desc" }
| くわしく |
get_post()(1件だけ取る)
| getEmDashEntry()
| くわしく |
the_title()
| {post.data.title}
| くわしく |
the_content()
| <PortableText value={post.data.content} />
| くわしく |
the_posts_pagination()
| nextCursorを使ってリンクを書く
| くわしく |
the_excerpt()
| {post.data.excerpt}(空のときの自動生成はない)
| くわしく |
the_permalink()
| post.idを使って/posts/…の形で組み立てる
| くわしく |
get_the_date()
| post.data.publishedAt.toLocaleDateString("ja-JP")
| くわしく |
get_the_modified_date()
| post.data.updatedAt.toLocaleDateString("ja-JP")
| くわしく |
previous_post_link() / next_post_link()
| 一覧を取り、今の記事の前後を探す | くわしく |
get_search_query()
| Astro.url.searchParams.get("q")
| くわしく |
the_post_thumbnail()
| <Image image={post.data.featured_image} />(emdash/ui)
| くわしく |
get_the_category()
| post.data.terms?.category
| くわしく |
the_author()
| post.data.byline?.displayName
| くわしく |
get_the_terms()
| post.data.terms?.分類の名前
| くわしく |
the_field()(ACF)
| {post.data.項目の名前}
| くわしく |
メニュー・ウィジェット
WordPress | EmDash | 記事 |
|---|
wp_nav_menu()
| getMenu("primary")と.map()
| くわしく |
子メニュー(sub-menu) | item.childrenを出力する
| くわしく |
wp_list_categories() / wp_tag_cloud()
| getTaxonomyTerms()と.map()
| くわしく |
wp_get_archives()
| 記事を取って、年月ごとに数える | くわしく |
register_sidebar()
| seedのwidgetAreas、または管理画面 | くわしく |
dynamic_sidebar()
| <WidgetArea name="sidebar" />
| くわしく |
管理画面
WordPress | EmDash | 記事 |
|---|
/wp-admin/
| /_emdash/admin/
| くわしく |
ログイン(IDとパスワード) | パスキー | くわしく |
投稿 | Posts | — |
固定ページ | Pages | — |
メディア | メディア | — |
カテゴリー / タグ | Categories / Tags | — |
外観 → メニュー | メニュー | くわしく |
外観 → ウィジェット | ウィジェット | くわしく |
SEOプラグインの入力欄 | 記事の編集画面のSEOパネル | くわしく |
XMLサイトマップのプラグイン | 最初から出力される/sitemap.xml | くわしく |
パンくずのプラグイン | 自作の共通パーツ | くわしく |
プレビュー | プレビュー | — |
カスタムブロック(ACFブロックなど) | プラグインでブロックを追加 | くわしく |
ユーザー → 新規追加 | ユーザー → ユーザーを招待 | — |
カスタム投稿タイプ | コンテンツタイプ | くわしく |
カスタムフィールド(ACF) | フィールド | くわしく |
再利用ブロック | セクション | くわしく |
親カテゴリー | seedのparent(絞り込みに子は含まれない) | くわしく |
リダイレクトのプラグイン / .htaccess | リダイレクト | くわしく |
ツール → インポート | インポート | — |
データベース
WordPress | EmDash | 記事 |
|---|
MySQL | SQLite(data.db) | くわしく |
wp_posts(投稿)
| ec_posts
| くわしく |
wp_posts(固定ページ)
| ec_pages
| くわしく |
wp_posts(添付ファイル)
| media
| くわしく |
wp_posts(リビジョン)
| revisions
| くわしく |
wp_postmeta
| 各テーブルの列(title、excerptなど) | くわしく |
wp_options
| options
| くわしく |
wp_users
| users
| くわしく |
wp_termsなど
| taxonomies
| くわしく |
wp_term_relationships
| content_taxonomies
| くわしく |
phpMyAdmin | sqlite3コマンド
| くわしく |
環境・運用
WordPress | EmDash | 記事 |
|---|
Localで「Start site」 | npm run dev
| くわしく |
WordPress本体のインストール | npm create emdash@latest
| くわしく |
wp-config.php
| astro.config.mjsと.env
| くわしく |
wp-content/uploads
| uploadsフォルダ(Node.js向けの場合)
| くわしく |
/feed/(RSS)
| src/pages/rss.xml.tsを自分で置く
| くわしく |
WP-CLI(wp post listなど) | npx emdash content list postsなど
| くわしく |
FTPでアップロード | コマンドで送る | — |
テーマをアップロードして有効化 | npm run buildで組み立て、npm run startで起動(Node.js向け)
| くわしく |
PHPが動くレンタルサーバー | Cloudflareか、Node.jsを動かせるサーバー | — |
WordPressのプラグイン | EmDash用のプラグイン(互換性はない) | — |
対応するものがないもの
- テンプレート階層:ファイルが自動で選ばれる決まりはありません。
src/pagesの中の場所がそのままURLになります - the_post()の切り替え:「今の記事」という考え方はありません。取り出した記事を、名前を付けて受け取ります
- フックとフィルター(
add_action、add_filter):テーマの中では使いません。同じ目的はプラグインの仕組みで扱います
次に読む記事
EmDashでCSSを読み込む4つの方法と、ページごとの読み分け