Plugin Jetpack- Trying to alter functions.php
-
Can anyone tell me what I am doing wrong. I was given these 2 codes to put into my functions.php file by “Jetpack”. I have tried several different plugins and nothing works. Is there something wrong with the code itself?
1.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:
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.
2.You can add Publicize support when registering the post type, like so:
// 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 );
[Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Plugin Jetpack- Trying to alter functions.php’ is closed to new replies.