Casse No-i // The unfiltered ramblings of a 20-something designer/dev with a bad case of the people-watchies... a girl who just needs to get it off her chest once in a while.
WARNING: This post assumes you have a working knowledge of php, HTML, CSS, and Wordpress/ Thesis functions and hooks. The following contains as-is code you are free to use AT YOUR OWN RISK. While I can assure you it works where I've used it, I make no disclaimer, warranty, or guarantee of its viability in your installation.
I'm currently finishing up a heavily modded Thesis Wordpress site for a client. Can't wait to release the link, but in the meanwhile, I want to share a little hack I wrote to change the default "Previous" "Next" archive/ post/ etc links that come loaded by default. In the process, my client also wants the single post pages to navigate between other posts in the same category ONLY, and for both sets of navigation to read the same (by default one uses post titles while the other simply "previous" and "next" text)
I looked around for solutions but what I found was either too much or too little of what I needed. So, naturally, I set out to write this myself ... A little swearing, voodoo magic, and some heated digging about the interwebs allowed me to kill all strange birds with one nimble stone. I'll explain more after I hand over the ugly...
Here's What You Do:
Drop this into your custom_functions.php & change the function parameters in red to how you'd like your links to read. If you're not sure what to do about those parameters, then refer to this post on Wordpress navigation for starters:
//BEGIN CUSTOM POST & PAGE NAV remove_action('thesis_hook_after_content', 'thesis_prev_next_posts');
remove_action('thesis_hook_after_content', 'thesis_post_navigation');
add_action('thesis_hook_after_content', 'nav_posty');
function nav_posty(){
?>
<div class="prev_next post_nav">
<?php if(is_single()){
?>
<p class="previous"><?php previous_post_link('← %link', 'Read More', TRUE); ?></p>
<p class="next"><?php next_post_link('%link →', 'Go Back',TRUE); ?></p>
<?php
}else{
?>
<p class="previous"><?php next_posts_link('← Read More'); ?></p>
<p class="next"><?php previous_posts_link('Go Back →'); ?></p>
<?php
}
?>
</div>
<?php
} //END CUSTOM POST & PAGE NAV
This is Why it Works (The Abridged Version):
First things first. 2 remove_action() calls remove the default single post and archive/index nav from the hook thesis_hook_after_content. The following add_action() places nav_posty() into the hook where those original functions used to be.
When it needs to, nav_posty() determines with a simple conditional statement whether or not the page in question is a single post or part of an index/archive and "does different stuff" depending on what it finds. It then uses HTML + built-in wordpress nav functions to output the proper links. For this particular exercise, I retained the default containers and classes so I didn't have to completely rework my formatting on the links ...
OK, Now Go Break Stuff
I mean.
Have fun trying out my filthy awesome code!
Hope you get as good use from it as I know I will. Bust it up, add images or blinking kittens, I don't mind! At the very least, I hope it helps you along your path to custom Thesis navigation enlightenment.