• Resolved Pam Blizzard

    (@pdblizzard)


    My php kungfu is not strong yet. I’m learning πŸ™‚

    I know I have to:
    add_post_type_support( 'state', 'genesis-simple-sidebars' );
    get to get some of my plugins to recognize my custom post types.

    But I have multiple custom post types (state, location, event and more)

    Instead of listing multiple “add_post_type_support(…” lines is it possible (and even more efficient) to list them all in one declaration? I checked the codex but didn’t see an example using an array.

    Thanks for helping me learn πŸ™‚

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Isn’t that art/skill called simply “php-fu”? πŸ˜‰ Whatever, right?

    That function only accepts array arguments for the feature (2nd parm) not post types. If you had multiple sidebars to support, you’d be able to pass them all in a single array. For multiple post types you need multiple declarations. You can compact the necessary code some by placing the post types in an array then running a foreach loop:

    $types = array('state', 'location', 'event', 'etc.',);
    foreach ( $types as $type ) {
       add_post_type_support( $type, 'genesis-simple-sidebars');
    }

    Thread Starter Pam Blizzard

    (@pdblizzard)

    Ah, php-fu, I like it πŸ™‚

    I have multiple 2nd params too so I’ll try that on my local play site and see what I can do.
    I’m just trying to do it “the right way” πŸ™‚

    Thank you for taking the time to answer, it’s very helpful. Have a great evening πŸ™‚

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add post type support – multiple post types in one declaration’ is closed to new replies.