WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type archive in Menu (3 posts)

  1. stueynet
    Member
    Posted 2 years ago #

    I have been having this issue for a while and have done some odd workarounds but I am wondering if anyone has any insight? So I have a custom post type. Call it Movies. So the URL to the archive page for all Movies would be site.com/movies

    I would like to make this a menu item using the menu interface. The only current way I can do this is to make custom link. This works ok, however I would really like the menu item class to be set as an ancestor or parent when you are within one of the custom post type single pages or taxonomy pages.

    It is possible to make a page with the slug that matches the custom post type but the class doesn't register and also it does not recognize custom post type single items and taxonomies as children.

    Anybody have any ideas on this?

  2. chaoticcreations
    Member
    Posted 2 years ago #

    I was having a similar issue with this, I fond a solution that isn't exactly the most elegant work-around, but it does the job.

    Firstly, make sure your body tag reads:
    <body <?php body_class(); ?>>

    This'll add a class to your body that will be unique to your custom post type. Next thing to do is go to your custom menu, make sure CSS Classes is turned on under Screen options, then give your custom link a class. You can then target it in CSS so it gets highlighted when under a particular body tag.

    I realise this probably isn't too useful for you 4 months on, but I thought I'd share it cos I went on a hunt for this info myself and A post explaining how to do it would've been useful!

  3. Aldi
    Member
    Posted 2 years ago #

    @stueynet:

    How about this plugin: Custom Post Type Archives in Nav Menus

Topic Closed

This topic has been closed to new replies.

About this Topic