Get The Most Recent Post of a Specific Term From Current Post


I’m developing a website for a webcomic and I’m having problems getting the page system to work. I have a custom post type set up for comic pages, and the pages are organized into volumes (with multiple volumes). I also have a custom taxonomy set up, with terms for “standard-page” and “volume-cover.”

What I’m trying to do is retrieve information on each standard page from the most recent volume page, specifically the volume title which exists in a custom field (using the ACF plug in) on each volume page. So for example, Volume 2 Page 15 would retrieve the title from the Volume 2 volume cover page and display it at the top of Page 15. I’m also attempting to implement an automatic page counter, so Page 15 would count backwards through all subsequent standard pages to the most recent page with the slug “volume-cover” and output that number (15) at the top. Unfortunately I’m proving quite clueless as to how to go about this and hope someone can point me in the right direction.

(Additionally I originally tried simply using parent-child pages, which would have made this process significantly easier, however this created a problem where it added the parent slug to the URL, which for various reasons that are too convoluted to go into here I can’t have and don’t want anyway – if you know how to simply remove this instead that is also a viable solution, however none of the answers I’ve tried have worked so far).

, , , , ZackAkai 1 year 2020-07-25T15:10:26-05:00 0 Answers 64 views 0

Leave an answer