Jared Heinrichs

  • Technology Blog
  • Winnipeg Computer Repair
  • Winnipeg Photographer
  • Cooking With Jared
You are here: Home / Web Applications / Wordpress / Wordpress next_post_link() to next post in Category

Oct 24, 2010 By Jared Heinrichs 2 Comments

WordPress next_post_link() to next post in Category

I was banging my head over this one. I did several searches and most people were recommending that people just use tags. I still don’t know how that would have helped. Before being told the answer I was thinking I would have to write a new Object in functions.php and re-write how next_post_link() works as editing the base code in WordPress is normally a no no. (Especially if you ever plan on updating the software).

Thankfully a guy named “Bob” recommended that I try something very simple that ended up working.

To get the Previous and Next post links to go to the next item in the category you need to use this code:

xhtml / PHP

next_post_link() to category 01

The important thing in the lines of code that get’s next_post_link() and previous_post_link() to base the linking on category is to add “, TRUE”.

PHP

next_post_link() to category 02

If you want to see the code in action just look at the bottom of this post. Since this is related to WordPress I’ve put it in the WordPress category. As long as there are no newer WordPress posts, this post should should only show a “previous post” link. It will take you back to the last post on WordPress.

I wanted to thank Bob again for helping me out with this info!

Filed Under: Wordpress Tagged With: How To

Comments

  1. Daniel says

    Aug 15, 2011 at 6:32 pm

    Yeah, but if you’ve got the post, categorized in 2 different categories, then what happens? 🙂

  2. Jared Heinrichs says

    Sep 4, 2011 at 9:55 am

    That’s why I never add one post to more then one category. If I need to add an item to more then one category I use Post Tags. If you’re starting out fresh I highly recommend planning your organization with Categories as being more general and Post Tags as being more specific.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Board Game Rules
  • Camera
  • Computer Hardware
    • Blackberry
    • drivers
    • iPad
    • Magic Jack
    • USB
  • Damn Small Linux
  • Exam Notes
  • Facebook
  • FREE Flashcards
  • Games
    • PC
      • League of Legends
    • Wii
    • xbox 360
  • Music
  • Networking
    • Cisco Certification
    • Mitel
    • Palo Alto Firewall
  • News
    • Google
    • Microsoft
  • Operating System
    • Active Directory (2003)
    • Android
    • Command Prompt
    • Damn Small Linux
    • Group Policy
    • Hyper-V
    • IIS
    • ISA 2006
    • Mac OS X
    • Microsoft Exchange Server
    • Powershell
    • Security
    • SME Server
    • Terminal Server 2003
    • Ubuntu Linux
      • Adito Web SSL VPN
      • OpenVpn-als
      • Webmin
    • Virtual Machine Manager
    • Windows 2003 SBS
    • Windows 2003 Server
    • Windows 2008
    • Windows 2008 R2
    • Windows 2012R2
    • Windows 7
    • Windows 8
    • Windows Command Line
    • Windows Deployment Services
    • Windows Server Backup
    • Windows Vista
    • Windows XP
  • Phones
  • Photography
  • Photos
    • Animals
    • Misc
    • Nature
    • Portraits
  • Portfolio
  • Programming
    • CSS
    • HTML
    • jQuery
    • MySQL
    • PHP
    • Script
  • Programs
    • Acrobat
    • Acrobat Reader
    • Adobe Dreamweaver
    • Adobe Illustrator
    • Adobe Photoshop
    • Anti-virus Software
    • Antivirus
    • Backup Exec
    • Bittorent
    • Blackberry BESADMIN
    • Internet Explorer 9
    • Lightroom
    • Microsoft Office
    • Netbeans
    • Onenote
    • Outlook
    • Shelby
    • Sysprep
    • Trend
    • Video Editing
    • Visual Studio
    • Windows Live Writer
    • WireShark
    • XP Mode
    • Zarafa
  • Recipe
  • Review
  • Software Links
  • Troubleshooting
  • Uncategorized
  • Videos
  • Web Applications
    • Brage
    • Google
    • Spiceworks
    • Wordpress
  • Web Browsers
    • Internet Explorer
  • Web Server
    • XAMPP
  • Winnipeg
    • ISP

Try searching this site!

Copyright © 2021 Winnipeg Web Design