• 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)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Hi senn39!

    Before we can resolve this are you able to provide a little more information for us?

    Where did you paste that code to? What is the custom post type you are trying to add support to? Is the module ( publicize ) active? Have you tried deactivating all other plugins to see if that resolves the issue? Have you tried using a bundled theme like Twenty Fourteen/Fifteen to rule out any theme conflicts?

    Thread Starter senn39

    (@senn39)

    Hi Jose,
    First I tried the plugin “My Custom Functions” then I tried “Css&JavaScript Toolbox”, and “Enlighter.” Then I tried putting it on the Functions.php file itself.

    I run a “Clipper” theme website so my custom post is “coupons.”

    Yes “Publicize” is active. The problem with it is that it only recognizes “Posts.” That is a known problem that they provide a fix for which is the 2 codes that I have but they aren’t working.

    I even tried for a week to teach myself php so that I could write a code myself but that was futile. Any help would be greatly appreciated.

    Thanks,
    Michele Senn

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Hi Michelle!

    The provided code will work for the product post type. Not sure if you changed it to coupons though.

    So the code would be:

    add_action('init', 'ms_add_publicize');
    function ms_add_publicize() {
        add_post_type_support( 'coupons', 'publicize' );
    }

    It has to match the name of the post type otherwise it will not work. I found this out when I tried adding support for Easy Digital Downloads and kept racking my brain why it wasn’t working. Turns out I misspelled download. Yeah. Who had the red face? Me!

    If you want that to remain when you switch themes, then you can keep using the “My Custom Functions” plugin that way you won’t lose that functionality if/when you switch themes. ??

    Hope that helps you out a little more. ??

    Any further questions let us know!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plugin Jetpack- Trying to alter functions.php’ is closed to new replies.