Opened 12 years ago
Closed 8 years ago
#21266 closed enhancement (maybelater)
Enhancements for page numbers links API
Reported by: | sirzooro | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4 |
Component: | Permalinks | Keywords: | has-patch needs-refresh needs-testing |
Focuses: | Cc: |
Description
Currently WordPress provides few functions to create links with page numbers embedded. Unfortunately they have some limitations:
get_pagenum_link()
- works on$_SERVER['REQUEST_URI']
only;
get_comments_pagenum_link()
- works on current post only;
_wp_link_page()
- works on current post only, returns HTML code and is private.
Because of these limitations in the past I have reimplemented these functions in my SEO plugin. Now I decided that it will be better if WP core will provide needed functionality.
Attached path introduces following changes for functions:
get_pagenum_link()
- added new$url
param, which can be used to pass any URL to function;
get_comments_pagenum_link()
- added two new params:$post
and$add_anchor
. The former one allows to pass any post object to function, the latter one tells function if it should append#comments
at the end of URL;get_post_page_link()
- new function. I moved code from_wp_link_page()
here and modified it so it can work on any post. Additionally it calls new filterget_post_page_link
before returning value.
Additionally these functions passes new argument(s) to filter at the end, so it will be easier for plugins to generate different pagination URLs.
I also modified _wp_link_page()
function (now it calls get_post_page_link()
) and removed @access private
from wp_link_pages()
(as I checked, it is called from themes code only).
Attachments (2)
Change History (7)
Note: See
TracTickets for help on using
tickets.
I have performed some additional tests and found that
get_comments_pagenum_link()
andget_post_page_link()
do not generate correct links when both page on front and index-based permalinks are used - generated permalinks does not include the `/index.php/' part. New patch fixes this bug.