コード例 #1
0
ファイル: custom-post.php プロジェクト: xalgorithm/amcf-wp
                        foreach ($cust_post_array as $opt) {
                            list($key, $val) = explode(':', $opt);
                            switch ($key) {
                                case 'labels':
                                    $name = strtolower(str_replace(' ', '-', $val));
                                    $labels = array('name' => __($val), 'singular_name' => __($val));
                                    break;
                                case 'menu_position':
                                    $menu_position = $val;
                                    break;
                                case 'thumbnail':
                                case 'excerpt':
                                case 'comments':
                                    $supports .= "'{$key}', ";
                                    break;
                            }
                        }
                    }
                    $supports = substr($supports, 0, strlen($supports) - 2);
                    eval('$support_array' . " = array( 'title', 'editor', {$supports} );");
                    $args = array('labels' => $labels, 'public' => true, 'menu_position' => $menu_position, 'supports' => $support_array, 'has_archive' => true);
                    register_post_type($name, $args);
                }
            }
        }
    }
}
$wpCustPost = new Custom_Post();
if ('Submit' == $_POST['sy_act']) {
    $wpCustPost->sy_create_custom_post();
}
コード例 #2
0
 function register_post_types()
 {
     Custom_Post::create(array('name' => 'Custom post'));
 }