Support » Plugins and Hacks » Publish To Apple News » Filter posts that are sent to Apple News?

  • Resolved John

    (@johnmcole)


    Is it possible to limit/filter the posts that we published to Apple News?

    Is there a filter that we can use to do this?

    Thanks,
    John

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Bradford Campeau-Laurion

    (@potatomaster)


    Most people use apple_news_skip_post and then apply their custom logic there.

    John

    (@johnmcole)


    Thank you Bradford. Something like this?

    function custom_apple_news_skip_push( $params ) {
        if ($this->id == ...) {
            return true;        
        } else {
            return false;
        }
    }
    add_filter( 'apple_news_skip_push', 'custom_apple_news_skip_push' );

    What parameters the does apple_news_skip_push filter expect?

    Plugin Author Bradford Campeau-Laurion

    (@potatomaster)


    Sure, something like that. However, the filter passes two params. The first is the boolean value (all filters pass the value to be modified as the first param) and the second is the post ID. Unless you were just intending params to be pseudocode there.

    In any case, I think you get the gist of it.

    John

    (@johnmcole)


    Cool. That’s what I was wondering. Thanks for the help!

    John

    (@johnmcole)


    Hi Bradford,

    Do you see any issues with this code? I’m not familiar with all of the ins and outs of the plugin and I want to make sure it’s not going to break something else.

    function gp_apple_news_skip_push($skip, $post_id) {
    
        $apple_news_id = get_post_meta( $post_id, 'apple_news_api_id', true );
        if ( ! empty( $apple_news_id ) ) {
            return $skip;
        }
    
        if (strpos(get_the_title($post_id), 'FTA:') === 0) {
            $skip = true;
        }
    
        return $skip;
    
    }
    add_filter( 'apple_news_skip_push', 'gp_apple_news_skip_push', 10, 2 );
    Plugin Author Bradford Campeau-Laurion

    (@potatomaster)


    Yes, should work though I’d obviously test it on your end first.

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