এখানে ফর্মের পৃষ্ঠাগুলির শিরোনাম সমর্থন করার একটি উপায়:
<!--nextpage(.*?)?-->
মূল সমর্থন হিসাবে একটি সাধারণ পদ্ধতিতে <!--more(.*?)?-->।
এখানে একটি উদাহরণ:
<!--nextpage Planets -->
Let's talk about the Planets
<!--nextpage Mercury -->
Exotic Mercury
<!--nextpage Venus-->
Beautiful Venus
<!--nextpage Earth -->
Our Blue Earth
<!--nextpage Mars -->
The Red Planet
আউটপুট অনুরূপ:

এটি বিশটি ষোল থিমে পরীক্ষা করা হয়েছিল , যেখানে আমাকে প্যাডিং এবং প্রস্থটি সামান্য সামঞ্জস্য করতে হয়েছিল :
.page-links a, .page-links > span {
width: auto;
padding: 0 5px;
}
ডেমো প্লাগইন
এখানে একটি ডেমো প্লাগইন ব্যবহার করে এর content_pagination, wp_link_pages_link, pre_handle_404এবং wp_link_pages_argsফিল্টার এই extenstion সমর্থন করার জন্য nextpage মার্কার ( পিএইচপি 5.4+ ):
<?php
/**
* Plugin Name: Content Pagination Titles
* Description: Support for <!--nextpage(.*?)?--> in the post content
* Version: 1.0.1
* Plugin URI: http://wordpress.stackexchange.com/a/227022/26350
*/
namespace WPSE\Question202709;
add_action( 'init', function()
{
$main = new Main;
$main->init();
} );
class Main
{
private $pagination_titles;
public function init()
{
add_filter( 'pre_handle_404', [ $this, 'pre_handle_404' ], 10, 2 );
add_filter( 'content_pagination', [ $this, 'content_pagination' ], -1, 2 );
add_filter( 'wp_link_pages_link', [ $this, 'wp_link_pages_link' ], 10, 2 );
add_filter( 'wp_link_pages_args', [ $this, 'wp_link_pages_args' ], PHP_INT_MAX );
}
public function content_pagination( $pages, $post )
{
// Empty content pagination titles for each run
$this->pagination_titles = [];
// Nothing to do if the post content doesn't contain pagination titles
if( false === stripos( $post->post_content, '<!--nextpage' ) )
return $pages;
// Collect pagination titles
preg_match_all( '/<!--nextpage(.*?)?-->/i', $post->post_content, $matches );
if( isset( $matches[1] ) )
$this->pagination_titles = $matches[1];
// Override $pages according to our new extended nextpage support
$pages = preg_split( '/<!--nextpage(.*?)?-->/i', $post->post_content );
// nextpage marker at the top
if( isset( $pages[0] ) && '' == trim( $pages[0] ) )
{
// remove the empty page
array_shift( $pages );
}
// nextpage marker not at the top
else
{
// add the first numeric pagination title
array_unshift( $this->pagination_titles, '1' );
}
return $pages;
}
public function wp_link_pages_link( $link, $i )
{
if( ! empty( $this->pagination_titles ) )
{
$from = '{{TITLE}}';
$to = ! empty( $this->pagination_titles[$i-1] ) ? $this->pagination_titles[$i-1] : $i;
$link = str_replace( $from, $to, $link );
}
return $link;
}
public function wp_link_pages_args( $params )
{
if( ! empty( $this->pagination_titles ) )
{
$params['next_or_number'] = 'number';
$params['pagelink'] = str_replace( '%', '{{TITLE}}', $params['pagelink'] );
}
return $params;
}
/**
* Based on the nextpage check in WP::handle_404()
*/
public function pre_handle_404( $bool, \WP_Query $q )
{
global $wp;
if( $q->posts && is_singular() )
{
if ( $q->post instanceof \WP_Post )
$p = clone $q->post;
// check for paged content that exceeds the max number of pages
$next = '<!--nextpage';
if ( $p
&& false !== stripos( $p->post_content, $next )
&& ! empty( $wp->query_vars['page'] )
) {
$page = trim( $wp->query_vars['page'], '/' );
$success = (int) $page <= ( substr_count( $p->post_content, $next ) + 1 );
if ( $success )
{
status_header( 200 );
$bool = true;
}
}
}
return $bool;
}
} // end class
ইনস্টলেশন : /wp-content/plugins/content-pagination-titles/content-pagination-titles.phpফাইলটি তৈরি করুন এবং প্লাগইনটি সক্রিয় করুন। যে কোনও প্লাগইন পরীক্ষা করার আগে ব্যাকআপ করা সর্বদা একটি ভাল ধারণা।
যদি শীর্ষস্থানীয় পৃষ্ঠাগুলি চিহ্নিতকারী অনুপস্থিত থাকে, তবে প্রথম পৃষ্ঠাগুলির শিরোনাম সংখ্যাযুক্ত ।
এছাড়াও যদি কোনও বিষয়বস্তু পৃষ্ঠা শিরোনাম অনুপস্থিত, যেমন <!--nextpage-->, তবে এটি অঙ্কিত হবে, যেমনটি প্রত্যাশিত।
আমি ক্লাসে পরবর্তী পৃষ্ঠার বাগ সম্পর্কে ভুলে গেছি WP, এটি content_paginationফিল্টারটির মাধ্যমে পৃষ্ঠাগুলির সংখ্যা পরিবর্তন করে দিলে তা দেখাতে পারে । এটি সম্প্রতি @ 35562 তে @ পিটারগুসেনের দ্বারা প্রতিবেদন করা হয়েছিল ।
আমরা এখানে ক্লাস চেকের pre_handle_404উপর ভিত্তি করে ফিল্টার কলব্যাক সহ আমাদের ডেমো প্লাগইনটিতে তা কাটিয়ে উঠার চেষ্টা করি, যেখানে আমরা তার পরিবর্তে যাচাই করি ।WP<!--nextpage<!--nextpage-->
টেস্ট
এখানে আরও কিছু পরীক্ষা দেওয়া হল:
পরীক্ষা # 1
<!--nextpage-->
Let's talk about the Planets
<!--nextpage-->
Exotic Mercury
<!--nextpage-->
Beautiful Venus
<!--nextpage-->
Our Blue Earth
<!--nextpage-->
The Red Planet
1 টির জন্য আউটপুট নির্বাচিত:

প্রত্যাশিত.
পরীক্ষা # 2
Let's talk about the Planets
<!--nextpage-->
Exotic Mercury
<!--nextpage-->
Beautiful Venus
<!--nextpage-->
Our Blue Earth
<!--nextpage-->
The Red Planet
৫ টির জন্য আউটপুট নির্বাচিত:

প্রত্যাশিত.
পরীক্ষা # 3
<!--nextpage-->
Let's talk about the Planets
<!--nextpage Mercury-->
Exotic Mercury
<!--nextpage-->
Beautiful Venus
<!--nextpage Earth -->
Our Blue Earth
<!--nextpage Mars -->
The Red Planet
3 জন্য আউটপুট নির্বাচিত:

প্রত্যাশিত.
পরীক্ষা # 4
Let's talk about the Planets
<!--nextpage Mercury-->
Exotic Mercury
<!--nextpage Venus-->
Beautiful Venus
<!--nextpage Earth -->
Our Blue Earth
<!--nextpage Mars -->
The Red Planet
আর্থ সহ আউটপুট নির্বাচিত:

প্রত্যাশিত.
বিকল্প
অন্য উপায় হ'ল এটি যুক্ত করার জন্য পৃষ্ঠাগুলির শিরোনামগুলি সমর্থন করার জন্য এটি সংশোধন করা হবে:
<!--pt Earth-->
সমস্ত পৃষ্ঠাগুলি শিরোনাম ( pts ) এর জন্য একটি মন্তব্যকে সমর্থন করাও সুবিধাজনক হতে পারে :
<!--pts Planets|Mercury|Venus|Earth|Mars -->
বা সম্ভবত কাস্টম ক্ষেত্রের মাধ্যমে?