♻️ Check wp_link_pages before rendering in content-single.blade.php (#3157)

Co-authored-by: Brandon <brandon@tendency.me>
This commit is contained in:
Jacek Gajewski
2023-12-08 17:44:28 +01:00
committed by GitHub
parent f53aee2c1f
commit 8109f7d039
3 changed files with 28 additions and 5 deletions

View File

@@ -26,11 +26,12 @@ class Post extends Composer
{ {
return [ return [
'title' => $this->title(), 'title' => $this->title(),
'pagination' => $this->pagination(),
]; ];
} }
/** /**
* Returns the post title. * Retrieve the post title.
* *
* @return string * @return string
*/ */
@@ -66,4 +67,18 @@ class Post extends Composer
return get_the_title(); return get_the_title();
} }
/**
* Retrieve the pagination links.
*
* @return string
*/
public function pagination()
{
return wp_link_pages([
'echo' => 0,
'before' => '<p>' . __('Pages:', 'sage'),
'after' => '</p>',
]);
}
} }

View File

@@ -1,3 +1,7 @@
@php(the_content()) @php(the_content())
{!! wp_link_pages(['echo' => 0, 'before' => '<nav class="page-nav"><p>' . __('Pages:', 'sage'), 'after' => '</p></nav>']) !!} @if ($pagination)
<nav class="page-nav">
{!! $pagination !!}
</nav>
@endif

View File

@@ -11,9 +11,13 @@
@php(the_content()) @php(the_content())
</div> </div>
<footer> @if ($pagination)
{!! wp_link_pages(['echo' => 0, 'before' => '<nav class="page-nav"><p>' . __('Pages:', 'sage'), 'after' => '</p></nav>']) !!} <footer>
</footer> <nav class="page-nav">
{!! $pagination !!}
</nav>
</footer>
@endif
@php(comments_template()) @php(comments_template())
</article> </article>