• Resolved sunnyt13

    (@sunnyt13)


    Hey there,

    I saw this in the update notice: “Custom Post Type UI now has the ability to skip content types with a WordPress filter”

    But am not sure where to find that filter?

    Thanks!

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

    (@tw2113)

    The BenchPresser

    If you’re talking about the part that I believe you are, it’d be any of these WordPress code filters:

    https://github.com/WebDevStudios/custom-post-type-ui/blob/master/custom-post-type-ui.php#L270-L294

    https://github.com/WebDevStudios/custom-post-type-ui/blob/master/custom-post-type-ui.php#L546-L570

    The easiest ones to use would be the dynamic filter ones, and they can be used as such. Imagine you have post types of “movie” and “tv_show” and then taxonomies of “genre” and “directors”. For whatever reason, you want to stop having “movie” and “directors” registered for you, but you don’t want to delete the CPTUI settings because you need to bring them back at a later time.

    You could use the following to temporarily prevent their registration:

    add_filter( 'cptui_disable_movie_cpt', '__return_true' );
    add_filter( 'cptui_disable_directors_tax', '__return_true' );
    

    Basically we use a WordPress core function that simply and merely returns true, without having to declare your own callback. Since we’re returning true, we’re telling CPTUI to indeed skip these two, and move on to the next ones.

    the other two filters shown will be a bit more general, and you’d need to check the current content type being iterated over with them. Seems potentially counter-intuitive, but they have their uses. For example those general ones could be used if you wanted to prevent ALL but one. If you want an example of that, I can type one up, but I think the examples above are going to be most useful to you out of the gate.

    Thread Starter sunnyt13

    (@sunnyt13)

    Hey Michael,

    Thanks for the quick response. Your short snippet looks to be exactly what I was looking for.

    Thanks!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Disabling post types’ is closed to new replies.