WP plugin: Next-Previous Post IMG
- plugin:
- Next-Previous Post IMG
- version:
- R1.1
- download:
- next-previous-img.zip
- source:
- next-previous-img.php
I’ve put together some WordPress plugins over the past few months, but haven’t posted anything on them (most were just described and linked on the WordPress wiki or my personal projects page). But the silence has ended. The one I’m on about here is a work in progress: Next-Previous Post IM(a)G(e), a small (ok, not all that small) redo of the WordPress next and previous post template tags, to allow images as links.
You can see Next-Previous Post IMG in operation here on guff—just look above search at the upper right of the page for the pretty link images. (Update: Switched to different mod of next/previous_post; ignore this note.)
To install, go through the regular rigamarole: download zip file, extract next-previous-img.php, upload to your WordPress plugin directory (wp-content/plugins), and activate the plugin. The tags to use are similar to the next_post() and previous_post() ones in WordPress, but have obvious differences:
Usage
<?php next_post_img('next_img', 'nonext_img', width, height, 'next', 'format', title); ?>
<?php previous_post_img('previous_img', 'noprevious_img', width, height, 'previous', 'format', title); ?>
Parameters
- next_img / previous_img
- (string) Path to graphic to display for next/previous post link. No default - should be set.
- nonext_img / noprevious_img
- (string) Path to graphic to display when no next/previous post link exists. Defaults to next_img / previous_img value/graphic.
- width
- (integer) Width (in pixels) for image as displayed. Defaults to true image width.
- height
- (integer) Height (in pixels) for image as displayed. Defaults to true image height.
- next / previous
- (string) Text to insert in image title/alt attributes. Defaults to
'Next post: '/'Previous post: '. This is prepended to title. - format
- (string) Format string for link.
'%'in string is replaced with the link/image, so'Go to %'will generate “Go to <a href=…<img src=…” Defaults to'%'- No idea who’d want to change it, but it’s here. - title
- (boolean) Use the title of next/previous post in title/alt attributes (
TRUE) or do not (FALSE). Defaults toTRUE.
Examples
(Examples use next_post_img(); I figure you’re smart enough to extrapolate for use with next_previous_img().)
This shows a very basic implementation, with values (paths to your images) set for next_img and nonext_img.
<?php next_post_img('/images/next.gif', '/images/next.gif' ); ?>
This has values (paths to your images) set for next_img and nonext_img, as well as forcing values (in pixels) for width (20) and height (12), and changes initial image’s title/alt attribute text to “next: “.
<?php next_post_img('/images/next.gif', '/images/next.gif', 20, 12, 'next: '); ?>
Author: Kaf Oseo
Categories: WordPress
Comments: (17) · Leave a comment · Comments RSS2 · Trackback URL
I don’t understand the usage of this plugin. Will it allow users to navigate individual images, like images in a post, as I have here:
http://www.bbiverson.com/2004/01/28/trip-to-hualien/
Only if they’re on individual posts/pages. The point of this plugin is to provide a replacement to the two built-in WordPress template tag functions:
These provide text links to the next or previous post when navigating individual posts on a weblog. Next-Previous Post IMG lets you use images for those links.
If you scroll up to the top of this page, the two small yellowish arrow graphics, just above search, demonstrate the use of this plugin. [Edit from the future: Layouts change...]Oooo… I like how you’ve implemented the plug-in. I didn’t even think about using it in that context. Niiiice!
Right now I’m having a small problem implementing this plug-in, but I’ve sent an e-mail to Podz and hopefully he can help me clear it up.
Once I get it all working properly, I am going to post this to the Pictorialis forums and I am sure that you will have a lot of very happy WordPress photobloggers out there.
Once again… many thanks. This was a big deal to me.
I’m all for happy bloggers. That they’re WordPress bloggers—and photobloggers to boot—is just a side benefit. Have fun with the plugin.
I’ve dropped it in my wordpress site ’single.php’ code and it works. However, when I added it to the ‘archive.php’ page, nothing appears. Any ideas?
@Jason, The plugin works like next_post/previous_post in that it provides links only for single post navigation. For what you’re looking for you’d need something that replaces posts_nav_link.
nice plug-in, however it doesn’t seem to be working correctly for me. i call my nav bar with an include if that makes any difference, and i’ve made sure that it’s after the wp loop. the problem being that it doesn’t link. the image shows up, but without the link. thoughts?
Kaf — great plugin, will be setting it up soon.. As Jason asked above, is there any plugin that exists to use images in the posts_nav_link function? Been searching all over… And way to hack yours to somehow use it for general next/previous site navigation?
Thanks!
ahhhh disregard…… looks like all ya gotta do is plug in
inside the call to post_nav_link :)
Went to look at urban image. it doesn’t help at all - well not that I could see, but then, I could be blind!!
Can you please explain the useage of your plugin clearer? I want to have something similar to what you’ve got: So that it is text that has “Next Post: Blah” when you hold the mouse over.
Regarding:
Can you explain how to do this? I’m trying to use this plugin in my Main Index template so I can have a link back to our previous day’s post.
Thanks!
Thanks a bunch for the plug in. Had a little trouble with the get image size function, so I just removed it. Otherwise, it saved me a bunch of trouble. Thanks again.
I managed to get this working. One thing I noticed though was that when I browse previous and next on single pages, it also see’s pages. Any updates for this?