Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php
  2. /**
  3. * Determines whether or not the current post is a paginated post.
  4. * @return boolean True if the post is paginated; false, otherwise.
  5. */
  6. function acme_is_paginated_post() {
  7. global $multipage;
  8. return 0 !== $multipage;
  9. }
  10. ?>
  11.  
  12. <?php if ( acme_is_paginated_post() ) { ?>
  13. <div class="post-pagination-toc">
  14. <!-- paginated post TOC display that checks headers across different poages and the displays all headers in as TOC's content uniformly across all paginated pages -->
  15. </div>
  16. <?php else { ?>
  17. <div class="normal-singlepage-toc">
  18. <!-- normal TOC display for single non-paginated post -->
  19. </div>
  20. <?php } ?>
  21.  
  22. <?php
  23. function TOC_new () {
  24. global $numpages;
  25. if ( is_singular() && $numpages > 1 ) {
  26. // This is a single post
  27. // and has more than one page;
  28. // Implement a General TOC to be displayed consistently multiple Pages and return values
  29. } else {
  30. // This is a single post
  31. // and has only one page;
  32. // implement TOC code for single pages.
  33. }
  34. ?>
  35.  
  36. function wpse_check_multi_page()
  37. {
  38. $num_pages = substr_count(
  39. $GLOBALS['post']->post_content,
  40. '<!--nextpage-->'
  41. ) + 1;
  42. $current_page = get_query_var( 'page' );
  43. return array ( $num_pages, $current_page );
  44. }
  45.  
  46. Array
  47. (
  48. [0] => 3
  49. [1] => 2
  50. )
  51.  
  52. Array
  53. (
  54. [0] => 1
  55. [1] => 0
  56. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement