LoginSignup
8
6

More than 5 years have passed since last update.

WordPress JetpackのMarkdownとパブリサイズ共有をカスタム投稿タイプで使う

Last updated at Posted at 2016-06-14

下記2パターンのうち、いずれかで。

カスタム投稿タイプ作成時に対応するパターン

wpcom-markdown がマークダウンで publicize がパブリサイズ共有。

<?php
// Register Custom Post Type
function my_custom_post_type() {
    $labels = array(
        'name'                => _x( 'Products', 'Post Type General Name', 'text_domain' ),
    );
    $args = array(
        'label'               => __( 'product', 'text_domain' ),
        'supports'            => array( 'title', 'editor', 'publicize', 'wpcom-markdown' ),
    );
    register_post_type( 'product', $args );

}
add_action( 'init', 'my_custom_post_type', 0 );

「公開」になっているカスタム投稿タイプ全てに対応するパターン

wpcom-markdown がマークダウンで publicize がパブリサイズ共有。

<?php
add_action( 'init', 'my_custom_init' );
function my_custom_init() {

    $args = array(
        'public'   => true,
        '_builtin' => false
    );
    $output = 'names'; // names or objects, note names is the default
    $operator = 'and'; // 'and' or 'or'

    $post_types = get_post_types( $args, $output, $operator ); 

    foreach ( $post_types  as $post_type ) {
        add_post_type_support( $post_type, array( 'publicize', 'wpcom-markdown' ) );
    }
}
8
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
6