WordPress Next/Previous Nightmare
I never write about stuff like this. But, I feel pretty damn good about figuring this out.
Here’s the problem. I’m working on a theme where I needed the last post thumb to be a image, that linked to the next page of posts. Normally you have a simple text link at the bottom, but we wanted an image instead. So, problem number 1 was replacing the 20th post thumb with an image.
This is an easy problem, right? I thought so. I looked into the code on index.php of this theme. GridPortfolio is the name of this theme, and it’s really easy to tweak and the theme is free. What I found was a complex little “while” statement that writes the news posts into the page. You tell it how many posts and how many per row–it does the rest. I’d already adjusted it for 5 rows with 4 per row. I talked to my buddy Adam Bert and he gave me some hints on how to target that last post. After fighting for a while, I was able to replace the last post with my new image–this created a new problem. What happens to that last post. Post number 20 just goes away, never to be seen again. This wasn’t the right way.
Another problem was how to replace the text link with an image. This seemed simple, but wasn’t. After the jump, there’s a full explanation of how I got that part to work.
WordPress has a built in solution for this. It creates simple text links for Next and Previous posts. But, it doesn’t do one important thing – it doesn’t actually evaluate when these should show up. Some code gets written either way. There are plugins with enhance WordPress’ next and previous abilities, but these were little more than shortcuts for text alterations–not the overhaul that I was seeking. I did find an example of someone who had a related issue with single post pages and the solution came into focus.
Standing on the shoulders of giants.
I took what he had done for single post pages and rewrote it for the index.php. Here’s what the standard WordPress Next/Previous block of code looks like…
<div><?php previous_post_link( '%link', '<span>' . _x( '←', 'Previous post link', 'twentyten' ) . '</span> %title' ); ?></div>
<div><?php next_post_link( '%link', '%title <span>' . _x( '→', 'Next post link', 'twentyten' ) . '</span>' ); ?></div>
<div><?php next_post_link( '%link', '%title <span>' . _x( '→', 'Next post link', 'twentyten' ) . '</span>' ); ?></div>
Mr. Roger Johansen from 456 Barea St. did this…
<ul> <?php if (get_adjacent_post(false, '', true)): // if there are older posts ?>
<li>Previous post: <?php previous_post_link('%link'); ?></li>
<?php endif; ?> <?php if (get_adjacent_post(false, '', false)): // if there are newer posts ?>
<li>Next post: <?php next_post_link('%link'); ?></li>
<?php endif; ?>
</ul>
<li>Previous post: <?php previous_post_link('%link'); ?></li>
<?php endif; ?> <?php if (get_adjacent_post(false, '', false)): // if there are newer posts ?>
<li>Next post: <?php next_post_link('%link'); ?></li>
<?php endif; ?>
</ul>
So, I took a few simple steps and about 25 rewrites to get to this…
<ul> <?php if (get_previous_posts_link(false, '', true)): // if there are older posts ?>
<li>Previous post: <?php previous_posts_link('Previous'); ?></li>
<?php endif; ?> <?php if (get_next_posts_link(false, '', false)): // if there are newer posts ?>
<li>Next post: <?php next_posts_link('Next'); ?></li>
<?php endif; ?>
</ul>
<ul> <?php if (get_previous_posts_link(false, '', true)): // if there are older posts ?>
<li>Previous post: <?php previous_posts_link('Previous'); ?></li>
<?php endif; ?> <?php if (get_next_posts_link(false, '', false)): // if there are newer posts ?>
<li>Next post: <?php next_posts_link('Next'); ?></li>
<?php endif; ?>
</ul>What is happening here? Instead of looking for a next or previous post, I’m looking for the “previous_posts_links” and the same goes for the “next_posts_links”. After that, I had to get the correct linking and change the text to match my preferred naming. Hopefully, this can help someone else with a similar issue.
Random #10 eZine – Available Now!
My first eBook is now available on the Apple bookstore. This digital zine is 100 pages long with work from 20 artists and is my first forray into this new form of publishing. Check out some samples below. Huge thanks to everyone who participated and if the world buys a few copies, then I’ll do more. It’s just a buck, spread the word.
Artwork by (in order of appearance) Hershel Baltrotsky, Sonia Yoon, Clint Woodside, Ryan Wallace, Rich Jacobs, Jim Houser, Kendrick Shackleford, Tom Maher, Ben Horton, Eric McDade, Chris Sembrot, Joseph Hart, Matt Sohl, Dave Delaney, Sam Croswell, Carlos Miaco, Matt Curtius, Amy S. Kauffman and Jordin Isip.
UK iBookstore –>
Spain iBookstore –> 
Australia iBookstore –>
Canada iBookstore –> 
France iBookstore –>
Germany iBookstore –> 
Old Work: Grey Joysticks on cardboard
This was from 2008-2009. That’s my best guess at least. Grey paint marker on a random piece of cardboard.
Girl x (Red) show video
It seems like yesterday, but this was almost a year ago, in August, 2010. This video was shot at the opening of the Girl x (Red) show in LA. My buddy Hershel was in the show and it was well worth the drive from San Diego to LA. This video was originally made for Living Proof Mag along with photos of the show.
Old Work: multi-use space exploratory drawing
Posted by jfx in architecture, art on August 2, 2011
The process of moving forces you to do a lot of things which aren’t so fun. Two things I do like doing are getting rid of things I don’t use and stumbling on things that I made in the past. I wrote about this once before and oddly, this drawing is from the same studio project. This is another one of these exploratory drawings, in some strange search for a way to combine mixed-use space inside one building. This one even has a key. Blue = Offices, Red = Circulation, Yellow = Public and White = Labs. If I remember correct, this was for an combination office/library/research facility. Below are some detail shots of the same drawing.
On Deck with Drew Dezort
Posted by jfx in movies & video, skateboarding on August 1, 2011
I created this video, with a lot of help from Drew Dezort for Roots, Culture Connect. The plan is to create a series of these. Who’s up next?
Random Numbers
It’s been a long-ass time since I built something random for no apparent reason. So here goes – a random number generator, built in flash (however unpopular that may be).
My 2010
2010 had a rough start. You may or my not remember that in the end of 2009 I lost my job. This situation created great difficulty in our household. We managed to get by with much cutting back, help from family and a willingness to wear many, many layers. Amy made lots of amazing food to ease the pain (see photos). In February I landed a temp job at the Bank of America and the timing couldn’t have been better. Bills needed to get paid. The next few months were pretty straight forward–get back on track. In June, I noticed an interesting job online and before I knew it I was offered an amazing job in California for Black Box Distribution. This was good news but life is not simple–lots of logistics are involved in moving across the country. We put our house up for sale (in the worst housing market). Amy is doing her best to maintain and I’m doing my best to do good work and balance that with home. I keep hoping that things will change for the better and some sanity will return to our lives.
Motivational Cubicle Signage
From February of 2010 until July I found myself back in the cubicle trenches. This was not my first cube run so I knew the ropes well. Something new hit me this time that I didn’t notice in my younger days. People decorate their cubes a lot. Some take a “home away from home” approach. Others try and simulate a cool office with design-y posters and hip toys. After a few weeks, I found myself doing the same without even realizing it.
One fine morning as I rolled into my cube, my neighbor asked, “How you doing?” My answer, channeling my best Allen Iverson, “Living every day like it’s my last!” For some reason this quote, in this context made me laugh all day long. This brought about my first ironic motivational quote poster. I was working in the kind of office that likes to put motivational quotes on the wall in gold letters, so this wink and nod to that was a huge bonus. In my downtime I created the “Live Every Day Like It’s Your Last” poster.
Once this first one was made the creative flood gates we’re opened. A series of 9 were made and you can download the whole set at the bottom of the post here. Some are famous quotes and others are my own invention. They all will raise your cube status and help you get through the day. Enjoy.
This could be you!!! Download the full set as a PDF here –> John Freeborn’s Motivational Cube Signs.PDF
Or, just grab your favorites as good ole’ JPG below.





































