How do I get CPT's to show in the admin bar? (5 posts)

  1. bobdobbs
    Posted 3 years ago #

    Hi. I'm trying to figure out how to create Custom Post Types.

    I've been mainly following this tutorial:

    I've created code for a CPT, modelling based on the code in that tutorial.

    Now that I've defined a CPT, I'd like to be able to create new posts of my type from the admin bar. The tutorial doesn't provide details on how to do this.

    So, how can I configure my CPT so that new posts of this type can be created from the admin bar?

  2. Drew Jaynes
    Docs Czar
    Posted 3 years ago #

    Hi bobdobbs,

    I suggest you take a look at the show_in_admin_bar parameter of register_post_type in the Codex. Essentially, it traces back several levels to the public parameter, which is set to false by default. The easy way to make sure your CPT shows all over the admin is to set public to true when you register the post type.

  3. bobdobbs
    Posted 3 years ago #

    Hi Drew.

    I have set public to true, as per the tutorial, but I'm still not seeing anything new in the admin bar.

    This is my function so far: http://pastebin.com/dREGva7J

  4. Drew Jaynes
    Docs Czar
    Posted 3 years ago #

    I don't know if this was a copy/paste error, but at the top of your pastbin, the 'a' in add_action is missing. I just tried your code and 'Profile Page' showed up in the '+ New' dropdown for me just fine: http://cl.ly/image/0w032k3U3z13

    Were you expecting something different?

  5. bobdobbs
    Posted 3 years ago #

    Yeah, that missing 'a' is just a copy/paste error.

    In my actual code I have the 'a'.

Topic Closed

This topic has been closed to new replies.

About this Topic