• Resolved jwgeertsma

    (@jwgeertsma)


    Hello! I’ve created a custom post type called “themes”. I’ve set the Archive and the Hierarchy options to true. I didn’t create any taxonomies. I’m just nesting the same custom post type as a child and it seems to work.

    The structure is set-up like this at the moment:

    
    - Themes (archive page)
       - Theme 1 (CPT "themes")
          -- Sub theme 1 (CPT "themes")
          -- Sub theme 2 (CPT "themes")
          -- Sub theme 3 (CPT "themes")
       - Theme 2 (CPT "themes")
          -- Sub theme 1 (CPT "themes")
          -- Sub theme 2 (CPT "themes")
          -- Sub theme 3 (CPT "themes")
    

    The issue that I’m having is that the archive page shows all the theme’s and subtheme’s. I would like it to only display the first level of theme’s. So it would be nice if the archive page should just list:

    
    Themes (archive page)
      - Theme 1 (CPT "themes")
      - Theme 2 (CPT "themes")
    

    And then when you open Theme 1 it should display the content of the custom post type which could be text and some images. Below it is should list:

     
     -- Sub theme 1 (CPT "themes")
     -- Sub theme 2 (CPT "themes")
     -- Sub theme 3 (CPT "themes")
     -- etc.
    

    Am I forgetting some kind of setting that I could activate to exclude all of the sub theme’s/posts from the automatic archive page? Or do I need to add some updates to a query somewhere? I’ve seen some examples where they add some specific override in the functions.php to adjust things. I just couldn’t get it to work in my situation.

    Every help would be appreciated. Thanks a lot!

Viewing 1 replies (of 1 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I know typically for archive pages like this, people use the pre_get_posts filter to conditionally include/exclude content from being considered. However, I’ve never considered how to potentially exclude children of other posts, since they’re all the same post type. Closest I can think of would be doing a query inside the pre_get_posts call to find all the child IDs and stash them in to post__not_in

    We don’t have any settings for this, so it’s not something missed here.

    Regarding subthemes, you’d probably want to edit the single-themes.php file to get the post ID, and query for all children of that ID, and do what you need to with that.

Viewing 1 replies (of 1 total)
  • The topic ‘Exclude child/nested posts from showing on the automatic archive page’ is closed to new replies.