WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Hierarchical custom post type query return only parent

[Resolved] Hierarchical custom post type query return only parent

  • I am using a custom post type of “newsletter” for a Newsletter section of my organization’s website. The idea is that each new “newsletter” will be a new edition of our newsletter. The post type is hierarchical, so children of the main “newsletter” will be the articles that the newsletter is comprised of.

    For example, a new “newsletter” might be called “Spring 2010” and it would have children called “Article 1,” “Article 2,” “Article 3,” an so on.

    with a structure resembling this:

    myorganization.org/newsletter/spring-2010/ (this would be the parent “newsletter”)
    myorganization.org/newsletter/spring-2010/article1/ (this would be the child of the “newsletter” post)

    I want to make an archive page for the “newsletter” post type, but I only want the main-level or parent posts to show up (I don’t want to list individual articles, the children of the “newsletter” posts).

    Is it possible to do a custom query that returns only the parents in a hierarchical custom post type? The closes example I can think of would be something like the wp_list_pages('depth=1'); that sets command, except for a custom post type of “newsletter.” I have no problem creating an archive page for all “newsletter” post types, but I can’t figure out how to limit it to parent/main-level posts.

    Any help would be much appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Hierarchical custom post type query return only parent’ is closed to new replies.
Skip to toolbar