Next and Previous Posts of Same Parent

Đã có trọn bộ đề thi thử THPT Quốc Gia 2022 các môn: vip.dethihsg247.com

I’m working on a website for a webcomic and I have a custom post type set up for comic pages. I have multiple series on the site and have made each comic page a child post of a parent (one parent for each series) to keep them organized and give the URLs some structure. What I’m trying to do now is add next and previous buttons to each comic page so the reader can easily move between them. I’m currently having two separate but related issues.

1. The comic pages use the same name and URL format, only separated by their parent. So for example the first page of series LCC looks like this:

Whereas the first page of series HTA looks like this:

WordPress allows this at a URL/slug level but it creates problems when trying to use the next and previous post functions. What happens is that the children of the parent which was created first (in this case LCC) take priority, which works perfectly when moving back and forward within LCC. However if I go to a page from HTA and try to move back and forward in there, it immediately kicks me out to the page with the appropriate slug but in LCC (so for example clicking “next” on hta/v01-001 should lead to hta/v01-002, but instead leads to lcc/v01-002 – clicking “previous” then leads to lcc/v01-001).

I’ve found some solutions that do away with the next/previous post functions and do it by incrementing the post ID, but that won’t work for me because I’ve set it up to paginate by menu order, which I’ve changed to be alphabetical (I want this all to work independently of post ID number). Here’s the code I used for that:

And my custom post code:

2. When I solve that problem, I then need to be able to restrict forward and backward navigation to only the siblings under the same parent. So upon reaching the last page of LCC, it should NOT go to the first page of HTA, or vice-versa.

My fallback option for all this is to just use a series taxonomy (which I had set up previously and worked), but I’m trying to eliminate as much unnecessary code and as many necessary things to check on each comic page as possible. I can do literally everything else I need to without a taxonomy just for that, so if it’s at all possible to do this with child/parent relationships please help me out!

Xin chào các bạn và quý Thầy Cô. Hãy nhập từ khóa mình muốn vào ô tìm kiếm trên Website để tìm kiếm mọi thứ hoặc trên google các bạn hãy nhập từ khóa + dethihsg247.com để tìm kiếm các bài viết của chúng tôi nhé.
  • Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
  • Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
  • Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.

Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com