How to limit autopost to Facebook only post with specific tag or term?

  • Michael Bissett

    Hey @rcespa, hope you're doing well this evening! :slight_smile:

    While something like this wouldn't be so simple of an endeavor, might I suggest an alternative here?

    Inside of:

    Facebook -> Facebook Settings -> Autopost to Facebook

    There's an option you can enable, called "Allow users to skip autopost", that would allow you to skip autoposting for specific posts via the post editor (see screenshots below).

    How does this sound? :slight_smile:

    Please advise,
    Michael

  • rcespa

    Hi Michael!

    Unfortunately the proposed solution does not fit my customer needs because the authors prefer to use tags instead of looking around for another checkbox to tick.
    If found a quick workaround altering the code in lib/class_wdfb_admin_pages.php adding the following snippet after line 1145, just after $post = get_post( $post_id )

    The code is:

    $t = wp_get_post_tags($post->ID);
                    $publishByTag = false;
                    foreach ( $t as $term ) {
                            if ( 'facebook' == $term->slug )
                                    $publishByTag = true;
                    }
    
                    if ( !$publishByTag )
                            return false;

    Then I enabled autopost for article post type and it gets done only if there is at least one term named "facebook".

    I know this is not the best approach because I have to reinsert this snippet at every update but it works as expected.

    Ciao,
    Roberto

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.