Query All Posts in a Custom Post Type Outside Loop & Display by it's Term
-
Hello. I’ve searched the net thoroughly for this answer and though I see similar solutions, none are quite what I need bc if it fixes one thing it breaks another.
So let’s say my custom post type is
pets
, one of my various taxonomies isdogs
and one of my various terms isyorkies
. I would like to show the last 5 added posts from mypets
custom post type but I’d like them to be displayed by whatever term name they’re associated with & linked to their term archive(taxonomy.php). What I am hoping to end up with is a code like this in my footer(outside the loop):<h3>Most Recently Updated Categories</h3> <li><a href="PERMALINK-TO-TERM-ARCHIVE">YORKIES</a></li> <li><a href="PERMALINK-TO-TERM-ARCHIVE">CHIHUAHUAS</a></li> <li><a href="PERMALINK-TO-TERM-ARCHIVE">COLLIES</a></li> <li><a href="PERMALINK-TO-TERM-ARCHIVE">ROTTWEILERS</a></li> <li><a href="PERMALINK-TO-TERM-ARCHIVE">POMERANIANS</a></li>
Basically every code I found wants me to specify a taxonomy & term name in the php code but seeing as how I want EVERY post in the
pets
custom post type to be queried no matter what taxonomy or term they have, I don’t think my code should specify the taxonomies & terms bc there are too many of them to list… Right?So could someone PLEASE write out the code from me based on this example?
- The topic ‘Query All Posts in a Custom Post Type Outside Loop & Display by it's Term’ is closed to new replies.