0

Is it possible to query the child posts of the single post your on?

i.e you have a custom post type called apples.

The parent page is... single-apple.php

On that page query and display all its own children, with corresponding link..

Apple Parent --apple child. --apple child. --apple child.

However, when you click on that it takes it to the own single.php for the the apple child.

What would that be called ask well.. single-apple-child.php ??

  • Is your post hierarchical ? And how you define/set the child post, any plugin ? – Shazzad Dec 15 '13 at 19:09
  • Sorry, what are you asking? You first ask if it is possible to query child posts then state "when you click on that", as if you've already accomplished what you are asking and then seem to asking about a template file instead. – s_ha_dum Dec 15 '13 at 19:32
  • Yes the custom post are hierarchical. Said parent post has children, the single.php for the parent post to display its subsequent children and link to a child single.php – user4630 Dec 15 '13 at 21:12
  • There is no actual question here. if you need to display different layout for root and leaf pages then you just detect whether the current page is one or the other and output whatever is needed. Obviously you are trying to ask something but if you want people to understand you will need to edit the question to make it clear what exactly are you asking – Mark Kaplun Dec 16 '13 at 5:48
0

You could do (untested):

if( get_post_type($post->post_parent) == 'apples' ){

get_template_part('single-apple-child')

} else {

/* the rest of your current single page */

}

Though there may be a better way!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.