SWELL│上書きできる関数・コードまとめ38選

SWELLはさまざまなフックが用意されていて、カスタマイズが容易です。

しかし使われている関数のコードも実は上書きできるので、さらに細かいカスタマイズも可能です。

そういった部分はif ( ! function_exists(....と記載されています。

本記事ではその関数・コードを38個全てまとめてみました。

ちなみにフックに関しては下記の記事にまとめております。

目次

著者

WEB制作をしているデジタルノマド
WordPressのカスタマイズが好きで、色々と自作しています。

WordPressのカスタマイズに困ったらご相談ください!

SWELLで上書きできる関数・コードまとめ38選

細かい解説の前に一覧も作成しました。

上書きできそうな関数を調べる

プラグインのString Locatorを使ってコードif ( ! function_exists(で検索した結果です。

関数名ファイルパス上書き
wp_use_widgets_block_editorwp-content/themes/swell/classes/Utility/Status.php×
get_pluginswp-content/themes/swell/classes/Theme_Data.php×
swl_parts__post_list_categorywp-content/themes/swell/lib/pluggable_parts/list_parts.php⚪︎
swl_parts__post_list_pvwp-content/themes/swell/lib/pluggable_parts/list_parts.php⚪︎
swl_parts__post_list_authorwp-content/themes/swell/lib/pluggable_parts/list_parts.php⚪︎
swl_parts__page_titlewp-content/themes/swell/lib/pluggable_parts/page_parts.php⚪︎
swl_parts__term_titlewp-content/themes/swell/lib/pluggable_parts/page_parts.php⚪︎
swl_parts__the_post_authorwp-content/themes/swell/lib/pluggable_parts/page_parts.php⚪︎
swl_parts__pnlinkwp-content/themes/swell/lib/pluggable_parts/page_parts.php⚪︎
swl_parts__head_logowp-content/themes/swell/lib/pluggable_parts/header_parts.php⚪︎
swl_parts__gnavwp-content/themes/swell/lib/pluggable_parts/header_parts.php⚪︎
str_containswp-content/themes/swell/lib/polyfill/php_functions.php⚪︎
echo_adwp-content/themes/swell/lib/shortcode.php
echo_tocwp-content/themes/swell/lib/shortcode.php
spbrwp-content/themes/swell/lib/shortcode.php
pcbrwp-content/themes/swell/lib/shortcode.php
echo_iconwp-content/themes/swell/lib/shortcode.php
review_starswp-content/themes/swell/lib/shortcode.php
post_linkwp-content/themes/swell/lib/shortcode.php
blog_partswp-content/themes/swell/lib/shortcode.php
ad_tagwp-content/themes/swell/lib/shortcode.php
balloonwp-content/themes/swell/lib/shortcode.php
full_wide_contentwp-content/themes/swell/lib/shortcode.php
custom_bannerwp-content/themes/swell/lib/shortcode.php
post_listwp-content/themes/swell/lib/shortcode.php
only_loginwp-content/themes/swell/lib/shortcode.php
only_logoutwp-content/themes/swell/lib/shortcode.php
echo_pr_notationwp-content/themes/swell/lib/shortcode.php
wp_render_layout_support_flagwp-content/themes/swell/lib/gutenberg.php×
swl_parts__postdatewp-content/themes/swell/lib/pluggable_parts.php⚪︎
swl_parts__title_datewp-content/themes/swell/lib/pluggable_parts.php⚪︎
swl_parts__pr_bannerwp-content/themes/swell/lib/pluggable_parts.php⚪︎
swl_parts__blog_linkwp-content/themes/swell/lib/pluggable_parts.php⚪︎
swl_parts__blog_cardwp-content/themes/swell/lib/pluggable_parts.php⚪︎
swl_parts__mv_btnwp-content/themes/swell/lib/pluggable_parts.php⚪︎
swl_parts__scroll_arrowwp-content/themes/swell/lib/pluggable_parts.php⚪︎
swl_parts__pickup_bannerwp-content/themes/swell/lib/pluggable_parts.php⚪︎
swl_parts__pr_notationwp-content/themes/swell/lib/pluggable_parts.php⚪︎
swl_get__a_catgorywp-content/themes/swell/lib/pluggable.php⚪︎

SWELLで上書きできる関数

SWELLで上書きできる関数を紹介します。

swl_parts__post_list_category

記事リストのカテゴリー。

投稿に関連付けられたカテゴリーを表示するための関数です。

場所はwp-content/themes/swell/lib/pluggable_parts/list_parts.php

swl_parts__post_list_pv

記事リストに表示するPV

場所はwp-content/themes/swell/lib/pluggable_parts/list_parts.php 

swl_parts__post_list_author

投稿リストの著者アイコンを取得する

場所はwp-content/themes/swell/lib/pluggable_parts/list_parts.php 

swl_parts__page_title

ページタイトル周りの表示に関する関数

場所はwp-content/themes/swell/lib/pluggable_parts/page_parts.php 

swl_parts__term_title

タームアーカイブページのタイトルを取得

場所はwp-content/themes/swell/lib/pluggable_parts/page_parts.php 

swl_parts__the_post_author

著者アイコンを取得する

wp-content/themes/swell/lib/pluggable_parts/page_parts.php 

swl_parts__pnlink

前後記事へのリンク。

wp-content/themes/swell/lib/pluggable_parts/page_parts.php

swl_parts__head_logo

ヘッダーロゴ

場所はwp-content/themes/swell/lib/pluggable_parts/header_parts.php 

swl_parts__gnav

グローバルナビ

場所はwp-content/themes/swell/lib/pluggable_parts/header_parts.php 

str_contains

str_contains 関数を定義するためのものです。

str_contains は PHP 8.0 から導入された関数で、ある文字列が別の文字列に含まれているかどうかを判定します。

場所はwp-content/themes/swell/lib/polyfill/php_functions.php 

swl_get__a_catgory

投稿に関連付けられたカテゴリーのリストから、特定の条件に基づいて1つのカテゴリーを選択して返すためのものです。

場所はwp-content/themes/swell/lib/pluggable.php

 SWELLで上書きできる関数│pluggable_parts.php

pluggable_parts.php 周りの上書きできる関数を紹介します。

swl_parts__postdate

公開日・更新日

場所はwp-content/themes/swell/lib/pluggable_parts.php 

swl_parts__title_date

投稿タイトル横の日付

場所はwp-content/themes/swell/lib/pluggable_parts.php 

swl_parts__pr_banner

プロモーションバナー

場所はwp-content/themes/swell/lib/pluggable_parts.php 

swl_parts__blog_link

関連記事テキストリンク

場所はwp-content/themes/swell/lib/pluggable_parts.php 

swl_parts__blog_card

関連記事ブログカード

場所はwp-content/themes/swell/lib/pluggable_parts.php 

swl_parts__mv_btn

MVボタン。※メインビジュアルのボタンのこと

場所はwp-content/themes/swell/lib/pluggable_parts.php 

swl_parts__scroll_arrow

MV用スクロールアイコン。※メインビジュアルのスクロールアイコン

場所はwp-content/themes/swell/lib/pluggable_parts.php 

swl_parts__pickup_banner

ピックアップバナー

場所はwp-content/themes/swell/lib/pluggable_parts.php 

swl_parts__pr_notation

PR表記

場所はwp-content/themes/swell/lib/pluggable_parts.php 

SWELLで上書きできる関数│shortcode.php 

shortcode.php周りの上書きできる関数を紹介します。

echo_ad

広告を挿入するためのカスタムショートコード [ad] を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

echo_toc

目次を挿入するためのカスタムショートコード [swell_toc] を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

spbr

スマホの改行をするためのカスタムショートコード [spbr]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

pcbr

スマホの改行をするためのカスタムショートコード [pcbr]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

echo_icon

SWELLアイコンをするためのカスタムショートコード [[echo_icon]]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

ショートコード例

[icon class="fas fa-heart"]

[アイコン class="fas fa-star"]

review_stars

レビュー用の星アイコンをするためのカスタムショートコード [review_stars] を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

post_link

ブログカードを表示するためのカスタムショートコード [post_link]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

blog_parts

ブログパーツを表示するためのカスタムショートコード [blog_parts]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

blog_parts

広告タグを表示するためのカスタムショートコード [ad_tag]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

blog_parts

ふきだしを表示するためのカスタムショートコード [speech_balloon]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

full_wide_content

フルワイドコンテンツを表示するためのカスタムショートコード [full_wide_content]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

custom_banner

カスタムバナーを表示するためのカスタムショートコード [custom_banner]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

post_list

投稿リストを表示するためのカスタムショートコード [post_list]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

only_login

ログイン中だけの表示をするためのカスタムショートコード [only_login]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

only_logout

ログアウト中だけの表示をするためのカスタムショートコード [only_logout]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

pr_notation

pr_notation表示するためのカスタムショートコード [pr_notation]を定義

同じ名前空間内で同名の関数を定義することによって上書きすることができる

場所はwp-content/themes/swell/lib/shortcode.php

まとめ

普段使ってるブロックや、記事の細かいパーツのコードが上書きできることがわかりました。

把握しておくと、テンプレートを使わずにより意図したカスタマイズができると思います。

Web制作のご依頼

SEOからデザインまで魅力的なWebサイトを制作いたします。

目次