• Resolved bcxdeveloper

    (@bcxdeveloper)


    Is there a way to have the “Share when publishing” toggle off by default. I want to be able to share when publishing just not for every post. I only need to share about 5% of the posts when publishing so toggling it off every time is a pain point.

    Is this possible?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Paulina H. (a11n)

    (@pehaa)

    Hi there,

    Currently, the “Share when publishing” toggle is set to be on by default, and there isn’t an option to have it off by default.

    Let’s look for some workarounds. How do you feel about manual sharing in those 5% of cases? Would that be a solution?

    You could also use a code snippet to control the sharing per post category and exclude the default post category. If your default post category is uncategorized this would look like so:

    /**
    * Do not trigger Publicize if the post uses the
    uncategorized category.
    *
    * @param bool $should_publicize Should the post be publicized? Default to true.
    * @param WP_POST $post Current Post object.
    */
    function jeherve_control_publicize_for_categories( $should_publicize, $post ) {
    // Return early if we don't have a post yet (it hasn't been saved as a draft)
    if ( ! $post ) {
    return $should_publicize;
    }

    // Get list of categories for our post.
    $categories = get_the_category( $post->ID );

    if ( is_array( $categories ) && ! empty( $categories ) ) {
    foreach( $categories as $category ) {
    if ( 'uncategorized' === $category->slug ) {
    return false;
    }
    }
    }

    return $should_publicize;
    }
    add_filter( 'publicize_should_publicize_published_post', 'jeherve_control_publicize_for_categories', 10, 2 );

    In the above snippet, you would need to replace uncategorized by the slug of the default category in your blog.

    Then you would always make sure that the default category is not used on the posts that should be shared.

    (Note:?This is not a code recommendation. We are unable to provide support for customizations under our Scope or Support.)

    I hope that the above points you in the right direction. Please let me know if you have further question.

    Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hi there, @bcxdeveloper,

    Do you have updates about that, do you still need help? We usually close inactive threads after one week of no movement, but we want to make sure we’re all set before marking it as solved. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.