Home Forums Front-end Issues replace the_content to ACF


replace the_content to ACF

  • I created some custom fields.
    I want the custom field replace the the_content, because a native ios app has problem of that field.
    I created the php, but to see the_content, you have to refresh the web page.
    The filter will not do, because the native apps do not see.

    The code is in a single.php.

      $postid = get_queried_object_id();
      $my_post = array(
          'ID'           => $postid,
          'post_content' => get_field('descrizione'),
      wp_update_post( $my_post );
  • You would need to add a new filter to the_content, this is a really basic example:

    add_filter('the_content', 'replace_content');
    function replace_content($content) {
      $value = get_field('your_replacement_content_field');
      if ($value) {
        $content = $value;
      return $content;
  • Your code is OK.

    The problem is the native application for iOS that does not see the filter. The application see only the database table, in particular POST_CONTENT.

  • I can’t help you with problems with iOS applications. If they don’t load the content in the same way that a web browser does then you’ll need to look into how to make that application do what it needs to do. If it’s looking directly at the database then I’d talk to whoever created that application since you’ll need to find a way to do this there.

  • After seeing your other question, I think I finally understand what you’re looking for.

    You need to create an acf/save_post filter with a priority >10. In your filter you can get the values from the ACF fields and save them to the content using the code from the OP.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘replace the_content to ACF’ is closed to new replies.