■環境
wordpress4.9.8
使用テーマ http://preview.themeforest.net/item/zephyr-material-design-theme/
■実現したいこと
現在、zephyrというテーマの機能で、ブログページで次の投稿と前の投稿が表示されるページネーションをONにする設定にしております。
この設定でカスタムポストタイプのページでもこの機能が有効になるのですが、
特定のカスタムポストタイプのページだけはこのページネーション機能をOFFにしたいとおもっております。
CSSでdisplay:noneするのではなく、出力条件を変えたいのですが、どのような記述にすればいいかお助けいただけませんでしょうか?
ページネーション部分を含むテーマのテンプレートファイルのコードは以下のようになっております。
PHP
1 2 <?php 3 while ( have_posts() ) { 4 the_post(); 5 6 $the_content = apply_filters( 'the_content', get_the_content() ); 7 8 // The page may be paginated itself via <!--nextpage--> tags 9 $pagination = us_wp_link_pages( 10 array( 11 'before' => '<div class="w-blog-pagination"><nav class="navigation pagination">', 12 'after' => '</nav></div>', 13 'next_or_number' => 'next_and_number', 14 'nextpagelink' => '>', 15 'previouspagelink' => '<', 16 'link_before' => '<span>', 17 'link_after' => '</span>', 18 'echo' => 0, 19 ) 20 ); 21 22 // If content has no sections, we'll create them manually 23 $has_own_sections = ( strpos( $the_content, ' class="l-section' ) !== FALSE ); 24 if ( ! $has_own_sections ) { 25 $the_content = '<section class="l-section"><div class="l-section-h i-cf">' . $the_content . $pagination . '</div></section>'; 26 } elseif ( ! empty( $pagination ) ) { 27 $the_content .= '<section class="l-section"><div class="l-section-h i-cf">' . $pagination . '</div></section>'; 28 } 29 30 echo $the_content; 31 32 // Post comments 33 if ( comments_open() OR get_comments_number() != '0' ) { 34 // Hotfix for events calendar plugin 35 if ( ! is_post_type_archive( 'tribe_events' ) ) { 36 ?> 37 <section class="l-section for_comments"> 38 <div class="l-section-h i-cf"><?php 39 wp_enqueue_script( 'comment-reply' ); 40 comments_template(); 41 ?></div> 42 </section><?php 43 } 44 } 45 } 46 ?> 47
自分で試したこととしては、
条件分岐はひとまず後で書くとして、ページネーションを非表示にできるようにするためfunctions.phpに
PHP
1remove_filter('the_content', 'pagination');
と書いてみましたが、変化なしでした。
アクションフックやフィルターフックの使い方自体が
よく理解できてないところもあり、かなり的外れなコードかもしれませんが、
何卒ご教示お願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/06 19:21 編集
2018/11/06 23:16
2018/11/07 04:05