Passing Quotation Marks via wp_link_pages

by Jeff Starr on Monday, June 12, 2006 3 Responses

According to the WordPress Codex 1, 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 Codex 2, wp_link_pages() is unable to pass quotes without causing errors.

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 loop 3.

References

About the author

[ Jeff Starr ]

Jeff Starr is a web developer, graphic designer and content producer with over 10 years of experience and a passion for quality and detail. Jeff is co-author of the book Digging into WordPress and strives to help people be the best they can be on the Web. + Follow Jeff on Twitter and subscribe to Perishable Press for awesome web-design content delivered fresh.


3 Responses
[ Gravatar Icon ]

August Klotz#1

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

[ Gravatar Icon ]

James#2

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

global $multipage;
if ($multipage) {
     echo ""; wp_link_pages("before=&amp;after=&amp;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.

[ Gravatar Icon ]

Perishable#3

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

If you have or need further information, contact me.



Attention: Do NOT follow this link!