-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publicize: Support custom post types #8
Comments
I believe you can already do that if the CPT has publicize set to true: https://github.com/Automattic/Jetpack/blob/master/modules/publicize/publicize.php#L345 |
Ah, wasn't aware of that. Just tested and it does work just fine 👍 |
Although it is possible to add the Publicize UI to the Custom Post Type editor, posts won't actually get publicized. We still need to work on synchronizing these posts with WordPress.com to push them to Social Networks. CPT support in Publicize is a popular request, as you can see in the original trac ticket here: |
@pippinsplugins does your solution work for all CPTs? Would you mind sharing it? |
@blobaugh I haven't tested anything yet, on my todo list. |
@pippinsplugins ah. Your previous post made me think you had. @lezama created a patch that seems to work. e.g: https://twitter.com/blobaugh_dev/status/423953713670004736. It will be in the beta next week and in the next full release. |
Just created the 8-github branch with the patch applied, it should support Publicize for custom post types. |
Did a final test. Looks great @lezama! Merged into master. |
Awesome! |
Is CPT support now supported for publicize or is the update still to come? Thanks. |
Update being released later today. |
Sweet, thanks kraftbj |
As @kraftbj mentioned we plan on releasing the new version of Jetpack later today, but you can already make the necessary changes to your Custom Post Type to be ready when Jetpack 2.8 comes out. There are 2 ways to add Publicize support to a Custom Post Type: 1 - If the Custom Post Type is declared via a third-party plugin or in your theme, you can use the add_action('init', 'my_custom_init');
function my_custom_init() {
add_post_type_support( 'your-custom-post-type-name', 'publicize' );
} 2 - If you created the Custom Post Type yourself, you can edit the CPT declaration to add // Register Custom Post Type
function custom_post_type() {
$labels = array(
'name' => _x( 'Products', 'Post Type General Name', 'text_domain' ),
// Other labels here
);
$args = array(
'label' => __( 'product', 'text_domain' ),
'supports' => array( 'title', 'editor', 'publicize', 'wpcom-markdown' ),
// Other parameters here
);
register_post_type( 'product', $args );
}
// Hook into the 'init' action
add_action( 'init', 'custom_post_type', 0 ); |
Thanks jeherve - so just adding 'publicize' to my 'supports' array in the CPT function in functions.php? |
That will do it, yes. |
Hey I have the following custom post type and I've added publicize to the supports array but on my test site subscribers aren't getting email notifcation of this cpt. Am i doing it wrong? Any help really appreciated. //Call for papers custom post type //
|
Testing/responding via e-mail in 1749169-t |
Thanks Brandon, do you need me to do anything - not sure what Matt |
The issue is on the WPCOM end, I believe -- something changed from when @lezama first added 2abcec5 -- we're tracking it down right now. The good news is that the fix should be purely on our end -- once we've got it fixed, no further changes on your side, and it'll magically start working again. This needs some unit tests so we can catch if some erstwhile changeset messes with it in the future. 💯 |
Thanks George, Do you have a rough timeframe for this fix at this point? Not being Thanks again for investigating. Kind regards, Matt On 01/02/2014 01:56, George Stephanis wrote:
|
Please note this is regarding the Publicize feature—the auto-publication to social media. |
As of version 2.8, if adding the CPT via an This was improved in SHA 5870427 to catch anything hooked in via priority less than 999, which will be pushed out in the next release. |
Thanks @kraftbj, works like a charm. |
CPT publicize still not working for me, even after init priority is set to 0. Help! Im on a deadline... |
@khawir Could you send us an email with more information about your site, your CPT, and how you added Publicize support to that CPT? Thanks! |
issues resolved... Thanks |
Summary: This MC page https://[private link]?tags=hello&sort=popularity&_locale=en&refresh=0 was failing with this error: ``` Fatal error: Uncaught Error: Call to undefined function has_meta() in /home/wpcom/public_html/public.api/rest/sal/class.json-api-post-base.php:123 Stack trace: #0 /home/wpcom/public_html/public.api/rest/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php(264): SAL_Post->get_metadata() #1 /home/wpcom/public_html/public.api/rest/json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php(130): WPCOM_JSON_API_Post_v1_1_Endpoint->render_response_keys(Object(WPCOM_Post), 'display', Array) #2 /home/wpcom/public_html/public.api/rest/json-endpoints/class.wpcom-json-api-get-post-v1-1-endpoint.php(70): WPCOM_JSON_API_Post_v1_1_Endpoint->get_post_by('ID', 7265, 'display') #3 /home/wpcom/public_html/public.api/rest/wpcom-json-endpoints/class.wpcom-json-api-read-site-post-endpoint.php(35): WPCOM_JSON_API_Get_Post_v1_1_Endpoint->callback('/read/sites/%s/...', 131300129, 7265) #4 /home/wpcom/public_html/wp-content/lib/reader-site-post/class.wpcom-reader-site-post.php(23): WPCOM_JSON_API_Read_Site_Post_Endpoint->callback('/read/sites/%s/...', 131300129, 7265) #5 /home/wpcom/public_html/wp-content/rest-api-plugins/endpoints/read-tags-cards.php(214): WPCOM_Reader_Site_Post::get_site_post(131300129, 7265) #6 /home/wpcom/public_html/wp-content/rest-api-plugins/endpoints/read-tags-cards.php(180): WPCOM_REST_API_V2_Endpoint_Read_Tags_Cards->process_es_results(Array) #7 /home/missioncontrol/public_html/reader/mobile-endpoints/cards/index.php(95): WPCOM_REST_API_V2_Endpoint_Read_Tags_Cards->get_cards(Array) #8 {main} thrown in /home/wpcom/public_html/public.api/rest/sal/class.json-api-post-base.php on line 123 ``` Searching around, it seems that the `has_meta` function is defined not in `wp-includes/post.php` but rather in `wp-admin/includes/post.php` I am a bit skeptical of this change though, because it seems like it could be potentially breaking many things. Test Plan: Apply patch on sandbox and see that cards are properly working for: https://[private link]?tags=hello&sort=popularity&_locale=en&refresh=0 I feel like it needs a bunch more testing, but not sure exactly what. Will definitely need to make sure that it doesn't break other things. Reviewers: bluefuton, gibrown Reviewed By: gibrown Subscribers: vickikb, sodrowski, jsnmoon, gibrown Tags: #touches_jetpack_files Differential Revision: D53904-code This commit syncs r218377-wpcom.
When using WP-Cli to run the event "wp_cache_full_preload_hook" causes the follow error > /webdir/bin/wp cron event run --due-now ``` PHP Fatal error: Uncaught Error: Call to undefined function wp_cache_debug() in /webdir/web/app/plugins/wp-super-cache/wp-cache.php:3163 Stack trace: #0 /webdir/web/wp/wp-includes/class-wp-hook.php(298): wp_cron_preload_cache() #1 /webdir/web/wp/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters('', Array) #2 /webdir/web/wp/wp-includes/plugin.php(515): WP_Hook->do_action(Array) #3 phar:///webdir/bin/wp/php/commands/cron-event.php(284): do_action_ref_array('wp_cache_full_p...', Array) #4 phar:///webdir/bin/wp/php/commands/cron-event.php(255): Cron_Event_Command::run_event(Object(stdClass)) #5 [internal function]: Cron_Event_Command->run(Array, Array) #6 phar:///webdir/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php(67): call_user_func(Array, Array, Array) #7 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array) #8 phar:///webdir/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php(372): call_user_func(Objec in /webdir/web/app/plugins/wp-super-cache/wp-cache.php on line 3163 Fatal error: Uncaught Error: Call to undefined function wp_cache_debug() in /webdir/web/app/plugins/wp-super-cache/wp-cache.php:3163 Stack trace: #0 /webdir/web/wp/wp-includes/class-wp-hook.php(298): wp_cron_preload_cache() #1 /webdir/web/wp/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters('', Array) #2 /webdir/web/wp/wp-includes/plugin.php(515): WP_Hook->do_action(Array) #3 phar:///webdir/bin/wp/php/commands/cron-event.php(284): do_action_ref_array('wp_cache_full_p...', Array) #4 phar:///webdir/bin/wp/php/commands/cron-event.php(255): Cron_Event_Command::run_event(Object(stdClass)) #5 [internal function]: Cron_Event_Command->run(Array, Array) #6 phar:///webdir/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php(67): call_user_func(Array, Array, Array) #7 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array) #8 phar:///webdir/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php(372): call_user_func(Objec in /webdir/web/app/plugins/wp-super-cache/wp-cache.php on line 3163 ``` This patch correct this based on deactivate/uninstall hooks which works on WP-Cli.
Add WhatsApp, Telegram, mail, update print
I'd really, really love to see custom post types (at least public ones) fully supported by by the Publicize module.
Are there any blocking reasons to not support custom post types?
The text was updated successfully, but these errors were encountered: