Bypass wordpress nextpage shortcode

After hours lost looking for a manner to disable the nextpage tag in WordPress, I found a solution using a function in my themes function.php:

add_filter(‘the_posts’, ‘disable_nextpage’);

function disable_nextpage($posts) {
$post_count = count($posts);
for ($i = 0; $i < $post_count; ++$i) {
$posts[$i]->post_content = str_replace(‘\n<!–nextpage–>\n’,”, $posts[$i]->post_content);
$posts[$i]->post_content = str_replace(‘\n<!–nextpage–>’,”, $posts[$i]->post_content);
$posts[$i]->post_content = str_replace(‘<!–nextpage–>\n’,”, $posts[$i]->post_content);
$posts[$i]->post_content = str_replace(‘<!–nextpage–>’,”, $posts[$i]->post_content);
}
return $posts;
}

With that code, the post is parsed before entering in the post_setupdata() function, where I remove the unwanted code. This is the simpler way I found to get WordPress not showing multipage for posts tagged with <!–nextpage–> If you have another suggestion, feel free to share it in the comments. And if a core developer read this, please think about adding a simple way to enable/disable functionalities like this (global variable, admin setup, …).

Source: http://wordpress.stackexchange.com/questions/34205/are-shortcode-functions-applied-while-rendering-the-content-or-are-they-execute

Advertisements
This entry was posted in IT stuff. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s