とても手順が多く、説明が難しい方法なのですが、思いついたので流れを書きます。
- カスタム投稿を使わず固定ページを採用する
- 固定ページにカスタムテンプレートを設定
- プラグイン Custom Field Suite (CFS) か Advanced Custom Fields (ACF) を導入
- ループ「店舗」を作成し、その配下にループ「すたっふ」を作成
- カスタムテンプレートで「店ループ」を取り出す
- 「すたっふループ」をランダムに取り出す(
$MyConten
に追記していく)
- 「すたっふ」が100人になったところで
<!--nextpage-->
を挿入
- 終わったところで
$post->post_content = $MyContent;
を実行
the_content();
と wp_link_pages();
を実行
↓↓↓カスタムテンプレートでの処理イメージ↓↓↓
PHP
1// こういうイメージ(あくまでイメージ)
2$staffCount = 0;
3$MyContent = '';
4foreach( 店舗ループ ) {
5 $temp_head = '<div class="shop">'.てんぽめい.えいぎょうじかん;
6 $temp_body = '';
7 $temp_foot = '</div>';
8 すたっふループ = ランダムにする関数を作る( すたっふループ );
9 foreach( すたっふループ ) {
10 $staffCount++;
11 if ( $staffCount > 100 ) {
12 if ( !empty( $temp_body ) ) {
13 $temp_body .= $temp_foot;
14 }
15 $temp_body .= "\n".'<!--nextpage-->'."\n".$temp_head;
16 $staffCount = 0;
17 }
18 if ( empty( $temp_body ) ) {
19 $temp_body .= $temp_head;
20 }
21 $temp_body .= '<div class="staff">'.すたっふじょうほう.'</div>';
22 }
23 if ( !empty( $temp_body ) ) {
24 $MyContent .= $temp_foot;
25 }
26}
27global $post;
28$post->post_content = $MyContent;
29setup_postdata( $post );
30remove_filter( 'the_content', 'wpautop' ); // うまくいかなければ消す。
31the_content();
32wp_link_pages();
わかりにくいですね、すいません。
以下はページ分割部分とカスタムフィールドプラグインの参考URLになります。
(参考1:固定ページでカスタムフィールドを利用したページ分割)
【Advanced Custom Fields: Repeater Fieldで<!--nextpage-->タグを使う方法 | 株式会社レオンテクノロジーはWebサイトを守るセキュリティ会社です】
https://www.leon-tec.co.jp/diary/2671/
PHP
1global $post;
2$post->post_content = $MyContent;
3setup_postdata( $post );
4remove_filter( 'the_content', 'wpautop' ); // うまくいかなければ消す。
5the_content();
6wp_link_pages();
7
8$MyContent = '<div class="xxx">.get_the_content().'</div>';
9if( have_rows( 'repeater_field_name' ) ):
10 while ( have_rows( 'repeater_field_name' ) ) : the_row();
11 $MyContent .= '<div class="xxx">'.the_sub_field( 'sub_field_name' ).'</div>';
12 endwhile;
13endif;
(参考2:Custom Field Suite プラグイン)
【Custom Field Suite ? WordPress Plugins】
https://ja.wordpress.org/plugins/custom-field-suite/
【ワードプレスのプラグインCustom Field Suiteの使い方 | 稼げる副業でお小遣いを稼ぐ方法】
http://www.moco358.com/archives/3278
【【WPプラグイン】Custom Field Suite(カスタムフィールドスイート)の使い方と表示方法|ZIGZOW】
http://zigzow.com/147
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。