WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Custom Post Template] Metabox dropdown in "Custom post types" (9 posts)

  1. arthurdent2003
    Member
    Posted 2 years ago #

    Hi There!

    I set up a custom post type- the I missed the dropdown menu to choose the kind of post-template. I just tried it dirts, "add_meta_box" in functions.php

    [Code moderated as per the Forum Rules. Please use the pastebin]

    But now - everytime I enter the post, it shows the default template in the dropdown, even if I selected the "Sold" button - I know - it's because it is hardcoded. But how can I just make wordpress check, if it is the selected one?

    Thank you!
    AD

  2. arthurdent2003
    Member
    Posted 2 years ago #

    anyone?

  3. Simon Wheatley
    Code for the People
    Posted 2 years ago #

    Rather than doing that, try following the instructions here (you'll need the latest version of the plugin): http://wordpress.org/extend/plugins/custom-post-template/other_notes/

  4. arthurdent2003
    Member
    Posted 2 years ago #

    hi simon,

    thank you! I'll give it a try.
    AD

  5. d5dhatch
    Member
    Posted 2 years ago #

    Hi Simon,
    I have custom post type I created with "Custom Post Type UI" plugin called products.

    I put this in my functions.php but I still don't get the meta box. Anything I'm doing wrong?

    <?php 
    
    /**
     * Hooks the WP cpt_post_types filter
     *
     * @param array $post_types An array of post type names that the templates be used by
     * @return array The array of post type names that the templates be used by
     **/
    function my_cpt_post_types($post_types) {
        $post_types[]='products';
        return $post_types;
    }
    add_filter( 'cpt_post_types', 'my_cpt_post_types' );
    
    ?>

    The plugin works great for standard posts but wont show the metabox on the custom post.

  6. Simon Wheatley
    Code for the People
    Posted 2 years ago #

    @d5dhatch – Are you using the latest version of the plugin? Can you also paste the code you're using to setup the Custom Post Type, please?

  7. arthurdent2003
    Member
    Posted 2 years ago #

    Dear Simon,

    is there any way to automatically only use custom post type (e.g.) "Love" -> with Custom Post Template "Love", custom post type "Peace" -> with Custom Post Template and so on.

    So that it automatically uses the specific cptemplate with specific post type?

    I uses this code - but I always have to make a choice:

    function my_cpt_post_types($post_types) {
        $post_types[]='love';
        $post_types[]='peace';
        $post_types[]='war';
    
        return $post_types;
    }
    
    add_filter( 'cpt_post_types', 'my_cpt_post_types' );

    thx!

    AD

  8. Simon Wheatley
    Code for the People
    Posted 2 years ago #

    Sorry Arthur, this isn't currently possible with the plugin.

  9. arthurdent2003
    Member
    Posted 2 years ago #

    ok - thanks anyway!

Topic Closed

This topic has been closed to new replies.

About this Topic