php - Wordpress: Display the content on an other page of the pagination -
i need display the_content() on other page of pagination of post. e.g. first page field called 'index'. page 2 'abstract' , page 3 shows author informations. on page 4 the_content should start.
the problem wordpress starts counting pages , on page 4 the_content shown if on page 4 (so after 4 times of < ! -- next page -->).
i did this:
$url = 'http://' . $_server['server_name'] . $_server['request_uri']; if (!preg_match('#/\d+/?#', $url)) { the_field("index"); } elseif(false !== strpos($url,'/2/')) { get_the_author_meta('first_name').' '.get_the_author_meta('last_name'); } elseif(false !== strpos($url,'/3/')) { the_field("abstract"); } else { the_content(); }
but, said, the_content() starts if page 4. know should deed way. how can page 4 page 1 the_content().
update clarify:
i want set out the_content() in theme file content-single.php display article in front end end. have pagination active wordpress paginates article whenever finds < !-- next page -->. that's native wordpress behaviour.
but want set content before the_content().
page 1: index page 2: abstract page 3: author page 4: start the_content() page 1 page 5: the_content() page 2 page 6: the_content() page 3
and on...
i'm doing code wrote above. check on page are. ($url,'/3/') page 3.
even if check page 4 (in else-part) , set out the_content() here wordpress puts out page 4 of the_content(), part after 4 times < !--next page-->. doesn't start the_content() on page 4 start on page 1 doesn't display it. internal page counter runs how.
how can start the_content() on page 4? or how can prevent wordpress counting pages?
the first thing i've noticed you're using regex match page's number ! should utilize $page (a wordpress-specific global variable).
$page (int) page of post, specified query var page. http://codex.wordpress.org/global_variables
however suggest using shortcode, much easier editing single.php
, gives more flexibility.
[section page='index'] // need build custom shortcode <!--nextpage--> [section page='abstract'] <!--nextpage--> [section page='author'] <!--nextpage--> <!-- page's 1 content --> <!--nextpage--> <!-- page's 2 content --> <!--nextpage--> <!-- page's 3 content -->
php wordpress pagination
No comments:
Post a Comment