Add function to display page links for paginated posts
Adds the function `understrap_link_pages()` which displays page links for paginated posts to avoid code duplication.
This commit is contained in:
parent
7385a059f0
commit
315d7c2e01
|
|
@ -199,3 +199,23 @@ if ( ! function_exists( 'understrap_comment_navigation' ) ) {
|
|||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'understrap_link_pages' ) ) {
|
||||
/**
|
||||
* Displays/retrieves page links for paginated posts (i.e. including the
|
||||
* `<!--nextpage-->` Quicktag one or more times). This tag must be
|
||||
* within The Loop. Default: echo.
|
||||
*
|
||||
* @return void|string Formatted output in HTML.
|
||||
*/
|
||||
function understrap_link_pages() {
|
||||
$args = apply_filters(
|
||||
'understrap_link_pages_args',
|
||||
array(
|
||||
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'understrap' ),
|
||||
'after' => '</div>',
|
||||
)
|
||||
);
|
||||
wp_link_pages( $args );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ msgstr ""
|
|||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"POT-Creation-Date: 2021-07-27T16:36:12+00:00\n"
|
||||
"POT-Creation-Date: 2021-07-27T23:49:41+00:00\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"X-Generator: WP-CLI 2.4.0\n"
|
||||
"X-Domain: understrap\n"
|
||||
|
|
@ -67,34 +67,19 @@ msgid "Posts by %s"
|
|||
msgstr ""
|
||||
|
||||
#. translators: %s: post title
|
||||
#: comments.php:37
|
||||
#: comments.php:36
|
||||
msgctxt "comments title"
|
||||
msgid "One thought on “%s”"
|
||||
msgstr ""
|
||||
|
||||
#. translators: 1: number of comments, 2: post title
|
||||
#: comments.php:44
|
||||
#: comments.php:43
|
||||
msgctxt "comments title"
|
||||
msgid "%1$s thought on “%2$s”"
|
||||
msgid_plural "%1$s thoughts on “%2$s”"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
#: comments.php:64
|
||||
#: comments.php:99
|
||||
msgid "Comment navigation"
|
||||
msgstr ""
|
||||
|
||||
#: comments.php:68
|
||||
#: comments.php:103
|
||||
msgid "← Older Comments"
|
||||
msgstr ""
|
||||
|
||||
#: comments.php:74
|
||||
#: comments.php:109
|
||||
msgid "Newer Comments →"
|
||||
msgstr ""
|
||||
|
||||
#: header.php:31
|
||||
msgid "Skip to content"
|
||||
msgstr ""
|
||||
|
|
@ -268,6 +253,22 @@ msgstr ""
|
|||
msgid "Edit %s"
|
||||
msgstr ""
|
||||
|
||||
#: inc/template-tags.php:184
|
||||
msgid "Comment navigation"
|
||||
msgstr ""
|
||||
|
||||
#: inc/template-tags.php:188
|
||||
msgid "← Older Comments"
|
||||
msgstr ""
|
||||
|
||||
#: inc/template-tags.php:194
|
||||
msgid "Newer Comments →"
|
||||
msgstr ""
|
||||
|
||||
#: inc/template-tags.php:217
|
||||
msgid "Pages:"
|
||||
msgstr ""
|
||||
|
||||
#: inc/widgets.php:103
|
||||
msgid "Right Sidebar"
|
||||
msgstr ""
|
||||
|
|
@ -333,12 +334,6 @@ msgstr ""
|
|||
msgid "It seems we can’t find what you’re looking for. Perhaps searching can help."
|
||||
msgstr ""
|
||||
|
||||
#: loop-templates/content-page.php:29
|
||||
#: loop-templates/content-single.php:35
|
||||
#: loop-templates/content.php:42
|
||||
msgid "Pages:"
|
||||
msgstr ""
|
||||
|
||||
#. Template Name of the theme
|
||||
msgid "Blank Page Template"
|
||||
msgstr ""
|
||||
|
|
@ -378,11 +373,9 @@ msgid "Search …"
|
|||
msgstr ""
|
||||
|
||||
#: sidebar-templates/sidebar-hero.php:28
|
||||
#: woocommerce/myaccount/orders.php:89
|
||||
msgid "Previous"
|
||||
msgstr ""
|
||||
|
||||
#: sidebar-templates/sidebar-hero.php:36
|
||||
#: woocommerce/myaccount/orders.php:93
|
||||
msgid "Next"
|
||||
msgstr ""
|
||||
|
|
|
|||
|
|
@ -21,15 +21,9 @@ defined( 'ABSPATH' ) || exit;
|
|||
|
||||
<div class="entry-content">
|
||||
|
||||
<?php the_content(); ?>
|
||||
|
||||
<?php
|
||||
wp_link_pages(
|
||||
array(
|
||||
'before' => '<div class="page-links">' . __( 'Pages:', 'understrap' ),
|
||||
'after' => '</div>',
|
||||
)
|
||||
);
|
||||
the_content();
|
||||
understrap_link_pages();
|
||||
?>
|
||||
|
||||
</div><!-- .entry-content -->
|
||||
|
|
|
|||
|
|
@ -27,15 +27,9 @@ defined( 'ABSPATH' ) || exit;
|
|||
|
||||
<div class="entry-content">
|
||||
|
||||
<?php the_content(); ?>
|
||||
|
||||
<?php
|
||||
wp_link_pages(
|
||||
array(
|
||||
'before' => '<div class="page-links">' . __( 'Pages:', 'understrap' ),
|
||||
'after' => '</div>',
|
||||
)
|
||||
);
|
||||
the_content();
|
||||
understrap_link_pages();
|
||||
?>
|
||||
|
||||
</div><!-- .entry-content -->
|
||||
|
|
|
|||
|
|
@ -34,15 +34,9 @@ defined( 'ABSPATH' ) || exit;
|
|||
|
||||
<div class="entry-content">
|
||||
|
||||
<?php the_excerpt(); ?>
|
||||
|
||||
<?php
|
||||
wp_link_pages(
|
||||
array(
|
||||
'before' => '<div class="page-links">' . __( 'Pages:', 'understrap' ),
|
||||
'after' => '</div>',
|
||||
)
|
||||
);
|
||||
the_excerpt();
|
||||
understrap_link_pages();
|
||||
?>
|
||||
|
||||
</div><!-- .entry-content -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue