How can I get next post id after current post id for custom post type

If you are using the code inside a custom post type template, then the get_next_post() will get the next post for you. Then you can use the ->ID and get it’s ID. So: $next_post = get_next_post(); $next_post_id = $next_post->ID; If you need their link, simply use next_post_link() or previous_post_link(). These functions use the global post … Read more

Render a different post/template from within the template_include action?

This was a bit tricky to solve your problem. the template_include filter executed after the main query processed the current request. If you can filter the current request (query_vars) and update it accordingly then WordPress will display any post/page you wanted to… Simply filter the query_vars with the request filter. Check the following snippet. But … Read more