{"id":7704415,"date":"2016-08-26T07:55:40","date_gmt":"2016-08-26T07:55:40","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/wp_link_pages_args-question\/"},"modified":"2016-09-01T18:19:34","modified_gmt":"2016-09-01T18:19:34","slug":"wp_link_pages_args-question","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/wp_link_pages_args-question\/","title":{"rendered":"wp_link_pages_args &#8211; Question"},"content":{"rendered":"<p>Hi,<\/p>\n<p>someone here who can help me with this little problem?<\/p>\n<p>I need to expand the following code. I need to show the total number of pages (like &#8230;10) in the pagination.<\/p>\n<pre><code>add_filter(&#039;wp_link_pages_args&#039;, &#039;wp_link_pages_args_prevnext_add&#039;);\n\/**\n * Add prev and next links to a numbered link list\n *\/\nfunction wp_link_pages_args_prevnext_add($args)\n{\n    global $page, $pages, $numpages, $more, $pagenow;\n\n    if (!$args[&#039;next_or_number&#039;] == &#039;next_and_number&#039;)\n        return $args; # exit early\n\n    $args[&#039;next_or_number&#039;] = &#039;number&#039;; # keep numbering for the main part\n    if (!$more)\n        return $args; # exit early\n\n    if($page-1) # there is a previous page\n        $args[&#039;before&#039;] .= _wp_link_page($page-1)\n        . $args[&#039;link_before&#039;]. $args[&#039;previouspagelink&#039;] . $args[&#039;link_after&#039;] . &#039;&lt;\/a&gt;&#039;\n    ;\n\n    if ($page&lt;$numpages) # there is a next page\n        $args[&#039;after&#039;] = _wp_link_page($page+1)\n        . $args[&#039;link_before&#039;] . $args[&#039;nextpagelink&#039;] . $args[&#039;link_after&#039;] . &#039;&lt;\/a&gt;&#039;\n        . $args[&#039;after&#039;]\n    ;\n    return $args;\n}<\/code><\/pre>\n<p>Thx very much, Frank<\/p>\n","protected":false},"template":"","class_list":["post-7704415","topic","type-topic","status-publish","hentry","topic-tag-code","topic-tag-pagination","topic-tag-wp_link_pages"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7704415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7704415\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=7704415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}