Hello,
my question:
can I use this function offers by jetpack?
How to use Publicize with your Custom Post Types
By default, Publicize is only triggered when you publish a new post. You can, however, extend this to other Custom Post Types. You have 2 options to add Publicize Support to a Custom Post Type:
You can add Publicize support to an existing post type thanks to the add_post_type_support() function. To do so, add the following code to a functionality plugin:
1
2
3
4
add_action(‘init’, ‘my_custom_init’);
function my_custom_init() {
add_post_type_support( ‘product’, ‘publicize’ );
}
You’ll need to replace “product” by your Custom Post Type name.
You can add Publicize support when registering the post type, like so:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Register Custom Post Type
function 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 );
}
// Hook into the ‘init’ action
add_action( ‘init’, ‘custom_post_type’, 0 );
If possible where must I insert the code?