コンテンツ本文へスキップ
0%

お知らせ

ショートコードのサンプル

2022年3月17日

[bloginfo hoge]

bloginfo(hoge)を表示

[bloginfo url]:https://tmp3.chichibu.net/wp

[bloginfo template_url]:https://tmp3.chichibu.net/wp/wp-content/themes/isurf3

[bloginfo name]:汎用テンプレートver3

[smpimg 300×200]

ダミー画像を生成

テンプレートの「/images/smp/」に「300×200.png」等を生成し、画像のURLを返す。 (既存があれば生成せず指定の画像のURLを返す)

[share_content 123]

他の投稿記事や固定ページの本文を表示する

[share_content 123]ならIDが123の本文を表示

[get_template_part hoge]

テンプレートPHPを表示

hoge.phpなら[get_template_part hoge]

hoge-abc.phpなら[get_template_part hoge abc]

[postlist]

投稿記事を表示

以下のオプションを指定可。

クエリの指定

オプション名 デフォルト 指定サンプル 備考
post_type post post_type="page,mypost" ※ポストタイプの指定。anyは全てのポストタイプ
posts_per_page 5 posts_per_page="10" ※1ページに掲載する記事数
order DESC order="ASC" ※並びの昇順・降順の指定
orderby menu_order date orderby="date" ※並び順
post_in 未指定 post_in="1,2,3" ※ポストIDで指定
post_not_in 未指定 post_not_in="1,2,3" ※除外するポストID
cat_in 未指定 cat_in="1,2,3" ※表示するカテゴリをIDで指定
cat_not_in 未指定 cat_not_in="1,2,3" ※除外するカテゴリをIDで指定
tag_in 未指定 tag_in="1,2,3" ※表示するタグをIDで指定
tag_not_in 未指定 tag_not_in="1,2,3" ※除外するタグをIDで指定
tax_in 未指定 tax_in="mytax+1-2-3,mytax2+4-5-6" ※表示するタクソノミーの名前とタームIDを指定
※3.0.8未満の接続詞は「>」。正常に動作しない場合はショートコード内の「”」を全て削除。
tax_not_in 未指定 tax_not_in=”mytax+1-2-3,mytax2+4-5-6″ ※除外するタクソノミーの名前とタームIDを指定
※3.0.8未満の接続詞は「>」。正常に動作しない場合はショートコード内の「”」を全て削除。
tax_relation AND tax_relation="OR" ※それぞれのタクソノミーの関係に'AND'か'OR'を指定
year 未指定 year="2021" ※表示する年を指定
month 未指定 month="1" ※表示する月を指定
day 未指定 day="31" ※表示する日を指定
s 未指定 s="text" ※検索キーワードを指定
offset 未指定 offset="10" ※オフセットを指定

掲載する項目の指定

オプション名 デフォルト 指定サンプル 備考
echo_date 掲載 echo_date="0" ※投稿日の掲載・非掲載。0指定で非掲載
echo_catlink 掲載 echo_catlink="0" ※カテゴリリンクの掲載・非掲載。0指定で非掲載
echo_termlink 非掲載 echo_termlink="tx_test,tx_test2" ※タームリンクの掲載・非掲載。タクソノミースラッグを指定で掲載
echo_excerpt 掲載 echo_excerpt="0" ※抜粋の掲載・非掲載。0指定で非掲載
echo_eyecatch 掲載 echo_eyecatch="0" ※アイキャッチの掲載・非掲載。0指定で非掲載
echo_pagenavi 非掲載 echo_pagenavi="1" ※ページナビの掲載・非掲載。1指定で掲載
echo_btn 非掲載 echo_btn="詳しくはこちら" ※詳細ボタンの表示・非表示

デザインの指定

オプション名 デフォルト 指定サンプル 備考
listinfo_class list-info listinfo_class="list-info-card rows-3" ※.list-info の class を指定
li_class 未指定 li_class="m-b-1" ※.list-info > li の class を指定
box_class 未指定 box_class="m-b-1" ※.list-info .box の class を指定
boximg_class 未指定 boximg_class="order-1" ※.list-info .box .box-img の class を指定
boxtext_class 未指定 boxtext_class="order-1" ※.list-info .box .box-text の class を指定
linktext_class 未指定 linktext_class="order-1" ※.list-info .box .box-text .link-text の class を指定
date_class 未指定 date_class="order-1" ※.list-info .box .box-text .date の class を指定
title_class 未指定 title_class="order-1" ※.list-info .box .box-text .title の class を指定
excerpt_class 未指定 excerpt_class="order-1" ※.list-info .box .box-text .excerpt の class を指定
cat_class 未指定 cat_class="order-1" ※.list-info .box .box-text .cat の class を指定
shortcode_class 未指定 shortcode_class="order-1" ※.list-info .box .box-text .shortcode の class を指定
btn_parent_class order-12 m-t-05 w-100p btn_parent_class="order-1" ※詳細ボタンの親の要素の class を指定
btn_class btn-def btn_class="btn-a" ※詳細ボタンの class を指定
eyecatch_size w100 eyecatch_size="medium" ※アイキャッチのサイズを指定
eyecatch_class 未指定 eyecatch_class="img-rounded" ※アイキャッチのclassを指定。未指定は共通設定の値を利用
eyecatch_no_url 未指定 eyecatch_no_url="/images/smp.png" ※アイキャッチが無い場合に掲載する画像のURLを指定

その他

オプション名 デフォルト 指定サンプル 備考
data_slick 未指定 data_slick='{"slidesToShow":3,"responsive":({"breakpoint":768,"settings":{"slidesToShow":1}})}' ※date-slickの値を指定できる。
※注意:「[」は「[」か「(」、「]」は「]」か「)」と記載。
ビジュアルモードで崩れるため「ver.3.1.15」以降は「()」を推奨。
※最外はシングルコーテーション、内はダブルコーテーションで記載。
havenot_return 現在、該当する投稿記事はございません。 havenot_return="メッセージ" ※該当記事がなかった場合の処理。指定メッセージに変更可。「0」を指定でfalseを返す。
shortcode 未指定 shortcode="scf_table id='123'" ※ショートコードの実行。実行結果を掲載する。注意:[]不要/シングルコーテーション
ajax_loading 未指定 ajax_loading="1" ※スクロール読み込みの実行
ajax_per_load 未指定 ajax_per_load="5" ※スクロール読み込み時のみ有効。1回に読み込む数。未指定(0)ならば、posts_per_pageの値を流用
only_li 未指定 only_li="1" ※li 要素内のみを返す。ulを省略。
fancybox3_ajax 未指定 fancybox3_ajax="1" ※fancybox3のajaxで詳細ページをリンクする。
■ajaxで読み込んだ記事一覧は、ボタンやセレクトで一覧を変更することが可能

class「.ajax-post-reset」とdata属性「data-shortcode」を設定。
「data-shortcode」に記載するショートコードの [ ] は省略する。
ショートコードのオプション「only_li="1"」は必須。※<li>要素のみ入れ替えるため。
ショートコードのオプション「havenot_return="0"」は必須。※取得できる記事がなくなった時に文言を返さないようにするため。
ショートコードのオプション「ajax_loading」は未指定か「0」を指定。※JSを再度読み込ませないため。

【例】
    <a class="ajax-post-reset" data-shortcode='postlist cat_in="1" only_li="1" havenot_return="0"'>新しいショートコード</a>
    <select class="ajax-post-reset">
        <option>-----</option>
        <option data-shortcode='postlist cat_in="2" only_li="1" havenot_return="0"'>新しいショートコード</option>
    </select>

[scf_table id="00"]

カスタムフィールドの表を表示

以下のオプションを指定可

オプション名 デフォルト 指定サンプル 備考
id 0 id="00" ※【必須】SCFポストIDで指定
cf_in false cf_in="cf1,cf2" ※nameで表示を指定
cf_not_in false cf_not_in="cf1,cf2" ※nameで除外を指定
rows 1 rows="2" ※tableの分割数を指定
div_class table-box w-100p div_class="table-hover" ※半角スペースで複数可。初期値上書き
dl_class false dl_class="w-100p" ※半角スペースで複数可
dt_class w-20p_pc dt_class="w-20p_pc" ※半角スペースで複数可。初期値上書き
dd_class w-80p_pc dd_class="w-50p_pc" ※半角スペースで複数可。初期値上書き
img_thumbnail thumbnail img_thumbnail="medium" ※画像のサムネイルを指定
img_class img-fluid hvr-opacity img_class="img-thumbnail" ※半角スペースで複数可。初期値上書き
img_a_class dsp-ib text-link-bodycolor img_a_class="dsp-b" ※半角スペースで複数可。初期値上書き
btn_class btn-a m-r-1 btn_class="btn-a" ※半角スペースで複数可。初期値上書き
link_text false link_text="cf1:テキスト:_blank:btn-a,cf2:テキスト:_blank:btn-b" ※リンクの形式を指定。
checkbox_text 、 checkbox_text=" " ※checkboxの分岐文字
checkbox_class false checkbox_class="dsp-ib box-a" ※checkboxのspanのクラス
wy_class normalize-post cf wy_class="test" ※WYSIWYGを囲むdivのクラス。半角スペースで複数可。初期値上書き
group_label_input false group_label_input="cf1,cf2" ※nameで指定。ループ内の初めのテキストタイプが見出しになる
group_class false group_class="dsp-ib" ※グループを囲むdivのクラス。半角スペースで複数可
only_dd false only_dd="true" ddのみ表示。dtを省略
only_val false only_val="true" 値のみを取得

※テキストとテキストエリアのURLはリンクに変更。

※テキストエリアの改行は<br>を追加。

※テキストとテキストエリアのGoogleマップの<iframe>は、<div class="google-maps">で囲まれる。

※テキストとテキストエリアのYoutubeの<iframe>は、<div class="youtube">で囲まれる。

※チェックボックス、ラジオボタン、セレクトボタンはラベルを掲載。

※チェックボックス、ラジオボタン、セレクトボタンを「key => value」の形式で指定した場合にkeyを「null」とすると掲載されない。
「null => 選択してください」「null => 未指定」などで指定。

※真偽値はラベルを掲載。

※日付・時刻フォーマットは、未指定の場合、Wordpressの日付時刻フォーマットで表示。指定があれば指定を優先。

コンテンツ本文の先頭へ戻る ページの先頭へ戻る