Support

Account

Home Forums Add-ons Flexible Content Field ACF Flexible Content + "Publish to Apple News" plugin

Solving

ACF Flexible Content + "Publish to Apple News" plugin

  • This is the Publish to Apple News plugin, which is Apple’s recommended way to publish WordPress posts to Apple News.

    The plugin works, in that it publishes Posts to Apple News, but there is no body content included when the article is published.

    This is because I am using a Flexible Content field to create a WordPress Post, so there is no the_content() for Apple news to grab.

    The plugin developer has posted a function demonstrating how to use a filter to grab ACF custom fields to pass to Apple News, see here: https://github.com/alleyinteractive/apple-news/issues/354.

    function add_content_to_apple_news($content, $ID) {
    
     $post = get_post($ID);
    
     //For podcasts custom post_type add in the teaser and the sponsors.
     if($post->post_type == 'podcasts' ) {
      $teaser = get_field('podcast_teaser', $ID, false);  //get data from ACF field
      $sponsors = get_field('podcast_sponsors', $ID, false);  //get data from ACF field
    
      $content = $teaser . $content . $sponsors;
     }
    
      return $content;
    }
    add_filter( 'apple_news_exporter_content_pre', 'add_content_to_apple_news', 10, 2 );

    This is a basic example, but my Flexible Content requires more configuration within the function, which is where I am looking for help.

    To keep things simple, let’s say I have a Flexible Content block called “Content”, which will appear multiple times within a Post. This is the ACF field I am looking to push to Apple News, via the function.

  • I know this post was a while ago, but did you figure out a solution? I am running into the same challenge. Thanks!

  • You would do the same thing that you would do when showing a flex field on the site.

    
    if (have_rows('flex_field', $post_id)) {
      while (have_rows('flex_field', $post_id)) {
        the_row();
        if (get_row_layout() == 'content') {
          // do something to show the content or add it
          $content .= get_sub_field('some_sub_field');
        }
      }
    }
    
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘ACF Flexible Content + "Publish to Apple News" plugin’ is closed to new replies.