This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Post Options for Custom Post Type

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #15339
    Jason Bobich
    Keymaster

    You’d do it like this:

    function my_post_meta( $setup ) {
        $setup['config']['page'][] = 'your_post_type';
        return $setup;
    }
    add_filter( 'themeblvd_post_meta', 'my_post_meta' );
    #15347
    Paul Littlewood
    Participant

    Perfect, thank you Jason.

    #16267
    david-wpck
    Participant

    Jason, to extend this question, how about for the “sidebars” options meta box normally available for posts and pages.

    #16268
    david-wpck
    Participant

    I tried using the “themeblvd_sidebar_meta_box” and “themeblvd_sidebar” filter and did not work.

    function my__sidebar_meta( $setup ) {
        $setup['config']['page'][] = 'customposttype';
        return $setup;
    }
    add_filter( 'themeblvd_sidebar_meta', 'my__sidebar_meta' );
    #16269
    david-wpck
    Participant

    Ok, I figured it out.
    I found the filter in the includes/admin/class-tb-sidebar-manager.php “themeblvd_sidebar_meta_box” from the theme-blvd-widget-areas plugin.

    I used this and it works. (function name and CPT name I changed for example)

    function my_cpt_meta_box( $args ) {
        $args['post_type']['page'] = 'my-customposttype';
        return $args;
    }
    add_filter( 'themeblvd_sidebar_meta_box', 'my_cpt_meta_box' );
    #16284
    david-wpck
    Participant

    Jason,
    Actually I just found a small issue with the function that initially worked.
    For just 1 post type, it works fine.
    I have 3 post types and it only shows on 1 of them. Cannot get it (sidebar meta box) to show on the other two. Any ideas?
    This is what I had:

    function my_cpt_meta_box( $args ) {
        $args['post_type']['page'] = 'my-customposttype';
        $args['post_type']['page'] = 'my-customposttype2';
        $args['post_type']['page'] = 'my-customposttype3';
        return $args;
    }
    add_filter( 'themeblvd_sidebar_meta_box', 'my_cpt_meta_box' );
    #16289
    Jason Bobich
    Keymaster

    $args['post_type']['page'] should be an indexed array of your post types. So you need to be adding each one to that array, not changing it into a string.

    For example, say you have an indexed array $fruits.

    $fruits = array( 'apples', 'oranges', 'pears' );

    Then you want to add “grapes” to that array. You’d do:

    $fruits[] = 'grapes';

    So your code should be like this:

    function my_cpt_meta_box( $args ) {
        $args['post_type']['page'][] = 'my-customposttype';
        $args['post_type']['page'][] = 'my-customposttype2';
        $args['post_type']['page'][] = 'my-customposttype3';
        return $args;
    }
    add_filter( 'themeblvd_sidebar_meta_box', 'my_cpt_meta_box' );
    #16294
    david-wpck
    Participant

    Thanks Jason!
    This makes me laugh at myself….
    It was staring at me the whole time, like looking for sunglasses on your head!
    Funny how we overlook the obvious sometimes.

    Thanks again for the extra pair of eyes.
    And thank you for continually moving forward with JS even though it’s not 1st priority, it’s a great framework.
    I used to just build my own but I have to say, letting someone else do all the updates (you!) is quite the time saver and you really pay attention to details, so thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.