List children on child post

Discussion in 'WordPress' started by Ruriko, Dec 21, 2014.

  1. #1
    I have a custom post type with children posts. If I'm viewing one of the children post how can I list other children posts that uses the same parent?
     
    Ruriko, Dec 21, 2014 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,810
    Likes Received:
    4,535
    Best Answers:
    123
    Trophy Points:
    665
    #2
    Edit the part of the template that shows the post, create a request for posts with the same parent and then display them
     
    sarahk, Dec 21, 2014 IP
  3. Ruriko

    Ruriko Well-Known Member

    Messages:
    4,023
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    130
    #3
    can you tell me the code? I'm not really a programmer
     
    Ruriko, Dec 21, 2014 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,810
    Likes Received:
    4,535
    Best Answers:
    123
    Trophy Points:
    665
    #4
    I don't know how your custom posts have been setup, so no. Give us the code you have used to create the custom post and we can have a go.
     
    sarahk, Dec 21, 2014 IP
  5. Ruriko

    Ruriko Well-Known Member

    Messages:
    4,023
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    130
    #5
    Here's the function on how my custom post type is registered
    add_action( 'init', 'register_cpt_episode' );
    
    function register_cpt_episode() {
    
    $labels = array(
    'name' => _x( 'Episodes', 'episode' ),
    'singular_name' => _x( 'Episode', 'episode' ),
    'add_new' => _x( 'Add New', 'episode' ),
    'add_new_item' => _x( 'Add New Episode', 'episode' ),
    'edit_item' => _x( 'Edit Episode', 'episode' ),
    'new_item' => _x( 'New Episode', 'episode' ),
    'view_item' => _x( 'View Episode', 'episode' ),
    'search_items' => _x( 'Search Episodes', 'episode' ),
    'not_found' => _x( 'No episodes found', 'episode' ),
    'not_found_in_trash' => _x( 'No episodes found in Trash', 'episode' ),
    'parent_item_colon' => _x( 'Parent Episode:', 'episode' ),
    'menu_name' => _x( 'Episodes', 'episode' ),
    );
    
    $args = array(
    'labels' => $labels,
    'hierarchical' => true,
    
    'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'comments' ),
    'taxonomies' => array( 'category', 'post_tag' ),
    'public' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    
    
    'show_in_nav_menus' => true,
    'publicly_queryable' => true,
    'exclude_from_search' => false,
    'has_archive' => true,
    'query_var' => true,
    'can_export' => true,
    'rewrite' => true,
    'capability_type' => 'post'
    );
    
    register_post_type( 'episode', $args );
    }
    Code (markup):
     
    Ruriko, Dec 21, 2014 IP