Trying to understand this:
format: (string) Format string for the link.
'%' in string will be replaced with the link, so
'Go to %' will generate "Go to <a href=..." Defaults
to '%'.
Is the string what goes into the <a href="link.php" title="string here"> or something else? This isn't clear.
Lorelle 23:45, 6 Mar 2005 (UTC)
- Also, there is no mention of the sequence the next post and previous post follow. There is a parameter for keeping it within a category, but what happens if it gets to the end of the category? Does it loop back or go up or down a category if that is an option? Does it follow by date order, modified order, or ID number? Alphabetically? We have no idea, only assumptions, so this needs to be explained in both tags.
- And...I notice that automatically it doesn't show the NEXT if there is no next. What if someone is using it in a sentence like
The next article you might like to
read is <?php next_post('%', '', 'yes', 'yes'); ?> and the
previous article is <?php previous_post('%', '', 'yes', 'yes'); ?>.
- The result is "The next article you might like to read is and the previous article...." So is there some kind of placeholder to fill in there? Is that what the "string" mentioned above is for?
- Lorelle 00:33, 7 Mar 2005 (UTC)
- Continuing with my editing and testing of the information herein, this is the tag I tried:
<?php previous_post('%', '', 'yes', 'yes'); ?>
- I've set it to format string % (which I still don't know exactly what the means), left the text blank, allowed the post title, and said "yes" to keeping it within the same category. I left off the last two parameters. To test this, I put it in the sidebar of a post, outside of the loop. It gives me the previous post chronologically to the visible post, but the previous post is in a completely unrelated category. Not just unrelated but unrelated up two categories and down two categories from each other. I tried TRUE instead of YES and got the same results. I've copied the tag exactly from the codex and variations, so I'm missing something, unless this isn't right in the Codex.
- Lorelle 03:36, 7 Mar 2005 (UTC)
Figured out a little of this:
<?php next_post('%', 'The next article you might
like to read is ', 'yes', 'yes', 1); ?>
<?php previous_post('%', ' and the
previous article is ', 'yes', 'YES'); ?>.
Results in "<a href="titleofnext">The next article you might like to read is title of next</a> <a href="titleofprevious">and the previous article is title of previous</a>.
Okay, if there isn't a way to have a text that may show up when there isn't anything there to post, then is there a way to eliminate the links around the whole thing? Just challenging the code so we can present it well. Lorelle 06:00, 7 Mar 2005 (UTC)
- I'll poke at this tag a bit when I've got some time, but it sounds like you answered some of your questions? I'm not sure what you mean by the last paragraph you wrote. --MDAWaffe 23:44, 7 Mar 2005 (UTC)
It boils down to this:
- If the post isn't there, (no next post) is there a way to have some default text included that is static and without a link? Like "The next post is coming soon but the previous post is <a href="prevposttitle.php">Previous Post Title</a> if you are interested." So the "coming soon" is the result of no post in the sequence.
- If "pre-text" or "pre-label" is included, can it be set to NOT be a part of the link, allowing the title of the post to be the link, such as "NEXT POST <a href="posttitle.php">Post Title</a>". Right now, it puts everything in a link.
- If the "keep next previous posts within the same category" is working, then I'm doing something wrong because I tried everything and setting that to YES gave me a post several categories away and definitely not in the same category. This might be a bug but I'm not good enough with the template tags to call it one.
This is in addition to the confusing paragraph on top of my musings here. Thanks for poking at this. With two different tags and some weak documentation, it's confusing. Lorelle 15:42, 8 Mar 2005 (UTC)
- When you're piloting a boat with more holes than you can account for, it tends to sink no matter what you do.
- No, not the way the tag currently functions. I ran into and addressed this issue with a plugin that uses images as links instead of text, in that you can specify a non-linked image for the ghost next/previous post. So one can rewrite the tag to do this, but WordPress fails to as is.
- Again, not as it now exists. A major behind the scenes problem with next_post() and previous_post() is that they're obvious pre-WP tags that haven't been updated or corrected much (witness the use of yes/no instead of boolean values for 'title' and 'in_same_cat', or the broken 'excluded_category'). Many of the nicer parameter additions to other tags, such as pre and post text, is not there in these guys.
- It's not. As I personally noted on that parameter: "This does not appear to function (pre-1.0/multiple categories?)"
- For me, part of the difficulty of documenting tags like these is that we must refer to parameters that probably shouldn't be parameters, don't work as you might expect them to, or just don't work at all. But then, that's what we signed on for.
- -Kaf 19:21, 8 Mar 2005 (UTC)
- Great info. Do you have a link to the plugin? As for the "This does not appear to function (pre-1.0/multiple categories?)" - This is totally not clear. I thought it meant that it didn't work pre 1.5 or something. If it doesn't work, then we need to take it out and make a note of it in the discussion or somewhere else instead of giving hope. Still, we have to make a lot of this clear in the Codex about how to use it and give good examples. Thanks for cleaning that up for me.
- And what about the similar tag posts_nav_link? How does that play into all of this?
- Always pushing the envelope, stamp, paper, pens, pencils.....Lorelle 20:15, 8 Mar 2005 (UTC)
- We can do our best to properly describe anything that doesn't function as expected, and perhaps file a bug report or two, but with the parameters there in the code, removing them from the documentation is not an option.
- posts_nav_link() is a different fish; I made a change in its description to try and make that clearer. And the plugin linked to on my projects page.
- -Kaf 21:27, 8 Mar 2005 (UTC)
- Found it. Great. I tried adding text only (1px graphic) and couldn't get it to work the "way I want it to" with text only. But I did notice that the graphic's location has to be pretty precise. I just put it in my Theme folder and it couldn't find it, so I put it in the plugin folder and it couldn't find it, so I had to put in the subfolders targeting right to it from the main folder. I am using base href so that might be part of the problem. My "image" folder is higher up out of the test folder. Great plugin, though. Might use it in the future.
- I posted a note in the posts_nav_link asking for a little more clarification for little ole dummy me. Thanks!Lorelle 21:37, 8 Mar 2005 (UTC)
Just a note (and some shouts and yodels) that I found a plugin that will allow text before AND after a NEXT and PREVIOUS that is not within a link in order to get what I want. Whew! It's from Eric Meyer's Next and Previous WordPress plugin. Now, the example code is very buggy on the page and I am now getting good enough with a surface knowledge of PHP to spot it and fix it. That is another cause for dancing around the room. I'll add this to a Lesson Tutorial I'm working on from all of these NEXT and PREVIOUS discussions. Wow!
Now, if I could just find a way to make the "stay in the same darn category" work....I am so demanding. Lorelle 22:22, 8 Mar 2005 (UTC)
I'm still not done torturing these poor tags. Discovered that these work on the SINGLE posts. It is mentioned in the leading into or the articles on these two tags, but it isn't very clear. Can we emphasis what this means. Also, if it only works on single posts (and the post_nav works only from the index.php...from my testing), does having Permalinks change this? Not clear at all. Just needs a little rounding out - but I don't know the words. Thanks! Lorelle 20:29, 11 Mar 2005 (UTC)
So, No Stay in Same Category?
So, Kaf, there are still no possibilities of the WP tags doing next and previous in the same category at all? The hunt was fruitless? $%*&#*&! I hope this changes soon. Lorelle 22:47, 24 Mar 2005 (UTC)
'in_same_cat' parameter fixed in 1.5.1
Fixed in 1.5.1 http://mosquito.wordpress.org/view.php?id=1252 , next_post() + previous_post() now works with the 'in_same_cat' parameter, constraining to the same category (+ works by date too).
I've just tested this. This change documents that next_post() + previous_post() are deprecated in favor of next_post_link() and previous_post_link() which are used in the updated default template.
These new tags are not documented in the codex. If they have any configurable parameters, I could not guess them.
I had wanted to use them (since it is reported that the the former are depreciated) but did not want to use post titles in the links, which is what these use.
At any rate, I was pleased to get the 'in_same_cat' function. I had been using the scriptygoddess plugin, which sorted by ID not Date, and looks like is now obsolete.
Echo 10:24, 22 May 2005 (UTC)