Closed sarpysarpy closed 8 years ago
Yeah, totally. We are doing this at WIRED. Here is some sample code that you could use:
add_action( 'pre_get_posts', 'wired_fb_instant_article_customize_feed_query' );
/**
* Set WP query variables for FB IA feed, so we can customize
* what posts are considered for the feed.
*
* Was once pre_get_posts
*
* @param $query WP_Query object.
*/
function wired_fb_instant_article_customize_feed_query( $query ) {
if ( $query->is_main_query() && $query->is_feed( 'fb' ) ) {
//Get original meta query
$meta_query = $query->get( 'meta_query' );
//Add our meta query to the original meta queries
$meta_query[] = array(
'key' => 'facebook_instant_feature',
'value' => 1,
'compare' => '=',
);
$query->set( 'meta_query', $meta_query );
}
}
Hi, would it be possible to include a custom field in Wordpress editing page to select which posts gets into fb instant articles instead of all of them?
Thank you.