Opened 12 months ago
Last modified 11 months ago
#20844 new feature request
Specify titles using <!-- nextpage -->
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | xoodrew@… |
Description
Hi,
I'm planning to code a plugin but maybe you're going to code it into WP core, so I prefer to ask before.
The idea is to modify <!-- nextpage --> code in order to give a title to every page, also better in SEO to have an url like www.wordpress.org/2012/my-article and www.wordpress.org/2012/my-article/conclusion/ instead of www.wordpress.org/2012/my-article/2/.
Maybe is possible to modify it this way: <!-- nextpageConclusion? -->
It's different from subpages because it will be usable on every post type, not even on pages, and you will create just one post, not more.
Last but not least you could have a page selector with titles not page numbers.
Thanks :)
Change History (17)
- Summary changed from <!-- nextpage --> to Specify titles using <!-- nextpage -->
Why not use a shortcode instead?
[nextpage title=Conclusion]
comment:4
in reply to:
↑ 3
DrewAPicture — 12 months ago
- Cc xoodrew@… added
Replying to scribu:
Why not use a shortcode instead?
[nextpage title=Conclusion]
+1 for the shortcode.
comment:5
arieputranto — 12 months ago
../my-article/conclusion : maybe using WP_Rewrite?
Title for it : How about post_meta?
Maybe good using shortcodes but in this case you need to insert two lines of code. With the
<!-- nextpage -->
Syntax first you can preserve legacy, then you can use just one line of code.
My thought was that [nextpage] could also handle the splitting, so you would still only need one line of code.
So leave intact nextpage and create a shortcode duplicate to split with titles?
Sounds good :)
Update: I'm coding it as shortcode, even if it is not really a shortcode because you cannot handle it using add_shortcode... anyway, I'm asking why using
$wp_rewrite->pagination_base
It returns the link www.site.com/2012/06/title/page/nextpagetitle, and if I use the regular
nextpage the link is www.site.com/2012/06/title/nextpagetitle, even if the core function uses $wp_rewrite->pagination_base
? :P
comment:10
in reply to:
↑ 9
duck_ — 11 months ago
Replying to sgr33n:
The pagination_base is used for paging of archives (e.g. category archives or date archives). It is not used for pagination of single posts or pages with multiple pages.
comment:11
sgr33n — 11 months ago
Thanks Duck,
Nevertheless, reading the code it seems that WP calls pagination_base also for single posts:
From wp-includes/link-template.php (line 1422)
function get_pagenum_link($pagenum = 1, $escape = true ) {
[...]
if ( $pagenum > 1 ) {
$request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' );
}
[...]
}
comment:12
sgr33n — 11 months ago
Almost complete, just time to solve some permalink issues that are driving me crazy o.O
comment:13
sgr33n — 11 months ago
Everything works now, even url rewrites but maybe something is wrong because even if I call a page like www.site.com/2012/06/posttitle/pagetitle/dasdsadas/dasdasdas/dasdsadsa/ WP returns the page, not even the 404 o.O can somebody help?
comment:14
sgr33n — 11 months ago
I'm proud to annunce that my first public WP Plugin is released in the first beta version :)
comment:15
scribu — 11 months ago
I took a look at your code and I think you could actually rely on the shortcode parsing and the old nextpage tag:
function nextpage_shortcode( $attr ) {
$global $nextpage_shortcodes;
$nextpage_shortcodes[] = $attr['title'];
return '<!--nextpage-->'; // Let WP handle splitting the content
}
add_shortcode( 'nextpage', 'nextpage_shortcode' );
Later, you can use the $nextpage_shortcodes global array to figure out which title to show.
comment:16
sgr33n — 11 months ago
Thanks for the suggestion :)
Maybe you can help me solving the infinite / and 404 not showing problem?
comment:17
sgr33n — 11 months ago
Anyway I tried your suggestion... my impression is that Wordpress handles the
<!--nextpage-->
Code before it handles shortcodes, so in this way you can see the not handled code in the post (source because html handles it as a comment).

It's: