Book Sale! Code WP2025 takes 20% OFF our Pro Plugins & Books »
Web Dev + WordPress + Security

Passing Quotation Marks via wp_link_pages

According to the WordPress Codex1, it is possible to pass quotation marks via the parameters of the function, wp_link_pages(). This would enable users to assign a particular css class or id to the function output, thereby providing greater design and behavioral control over that particular object. But alas, as reported several times in the WordPress Codex2, wp_link_pages() is unable to pass quotes without causing errors.

The fix

To fix this, we open template-functions-post.php and find wp_link_pages(), which is located around line #121 (for WP 2.0.2). The fix is easy, simply edit the <p> in the following lines:

$r['before'] = '<p>' . __('Pages:');
$r['after'] = '</p>';

For example, if you wanted to wrap the function output with a <div class="foo"> and subsequent </div>:

$r['before'] = '<div class="foo">' . __('Pages:');
$r['after'] = '</div>';

Upload and done. Do not forget to eliminate the before= and after= parameters when calling the function from the loop3.

Footnotes

About the Author
Jeff Starr = Web Developer. Book Author. Secretly Important.
.htaccess made easy: Improve site performance and security.

3 responses to “Passing Quotation Marks via wp_link_pages”

  1. August Klotz 2006/06/12 8:34 pm

    This works great but isn't always necessary. Often, some creative CSS works just as well..

  2. Rather than editing the core code I’d recommend you do the following:-

    global $multipage;
    if ($multipage) {
         echo ""; wp_link_pages("before=&after=&pagelink=%");
         echo "";
    }

    This allows you to style the thing up as much as you need and come upgrade time you don’t need to do anything special.

  3. Perishable 2007/07/29 9:50 am

    Very keen, James!

    That should definitely come in handy next time around the redesign loop (so to speak)..

    Thanks for sharing!

Comments are closed for this post. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
BBQ Pro: The fastest firewall to protect your WordPress.
Thoughts
Launching my new plugin, Head Meta Pro 🚀 Complete meta tags for WordPress.
Migrating sites to a new server, so far so good. Please report any bugs, thank you.
Arc browser looked good but lost me at “account required”. No browsers do that.
Finishing up the pro version of Head Meta Data plugin, launch planned this month.
Finally finished my ultimate block list to stop AI bots :) Blocks over 400+ AI bots!
After 10 years working late at night, my schedule has changed. I am now a “morning person”, starting my day at 6am or earlier.
Nice update for Wutsearch search engine launchpad. Now with 19 engines including Luxxle AI-powered search.
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.