Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

class GWP_Post_Series

main class for the plugin a part of GWP tutorial : https://generatewp.com/group-post-series-custom-taxonomy

/*
* GWP_Post_Series
*/
class GWP_Post_Series{
    /*
     * $tax_name 
     * used to avoid writing post series
     * taxonomy name over and over.
     * @var string
     */
    public $tax_name = 'GWP_post_series';   
    /*
     * __construct 
     * Class constructor
     */
    function __construct(){}
 
    /*
     * hooks
     * Used to hook all our functions
     * @return void
     */
    function hooks(){}
 
    /*
     * register_post_series_taxonomy
     * this will be generated using our Taxonomy generator
     * @return void
     */
    function register_post_series_taxonomy(){}
 
    /*
     * the_content
     * Used to add the post series box to the single post view
     * @param  string $content post content
     * @return string 
     */
    function the_content( $content = null ){}
 
    /*
     * has_post_series 
     * used to determine if a post is a part of a post series
     * @param  int  $post_id  post ID
     * @return boolean        true if the post is a part of a post series
     */
    function has_post_series( $post_id ){}
 
    /*
     * get_posts_in_series
     * Get post ids of posts in a series by series ID 
     * @param  int $series_id series term ID
     * @return array|boolean  array of post IDs or false if none found 
     */
    function get_posts_in_series( $series_id ){}
 
    /*
     * get_post_series
     * Get post series term object by post ID
     * @param  int $post_id post ID
     * @return WP_Term|boolean  series term object if found or false if not.
     */
    function get_post_series( $post_id ){}
 
    /*
     * create_post_series_box
     * Create post series box html markup
     * @param  int      $current_id         current post ID.
     * @param  array    $posts_in_series    array of post IDs.
     * @param  WP_Term  $series             Post Series taxonomy term.
     * @return string                       HTML markup of post series box
     */
    function create_post_series_box( $current_id, $posts_in_series, $series ){} 
}