Viewing 5 replies - 1 through 5 (of 5 total)
  • This is exactly what I want to do as well.

    Simon, any thoughts?

    Thread Starter Pancho Perez

    (@lonchbox)

    I think with a filter in funcionts.php is more than enough ??

    I answered my own question, the code to add is in the “Other Notes” section of the plugin page. Simply add it to functions.php and add your custom post type name:

    /**
    * 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[] = ‘movie’;
    $post_types[] = ‘actor’;
    return $post_types;
    }
    add_filter( ‘cpt_post_types’, ‘my_cpt_post_types’ );

    This is probably not the best way but works: I reset $post_types array or update first position.

    function my_cpt_post_types( $post_types ) {
        $post_types = [];
        $post_types[] = 'projetos';
    
        return $post_types;
    }

    or

    function my_cpt_post_types( $post_types ) {
        $post_types[0] = 'projetos';
    
        return $post_types;
    }
    Thread Starter Pancho Perez

    (@lonchbox)

    It works! ?? thanx @gtso86

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Use only for Custom Post Type’ is closed to new replies.