Get ACF gutenberg block data from custom post type

1.3k views Asked by At

I running into some problems with ACF Gutenberg blocks.

I have registered a Gutenberg block to be used in a custom post type called "Portfolio" Through a normal wp_query i can display the custom post type on the homepage. But i can not get the ACF Gutenberg block data to show?

Below is the code im currently using.

<?php

// WP_Query arguments
$args = array(
    'post_type'              => array( 'portfolio' ),
    'post_status'            => array( 'publish' ),
    'nopaging'               => false,
    'posts_per_page'         => '5',
  );

  // The Query
  $query_portfolio = new WP_Query( $args );

  // The Loop
  if ( $query_portfolio->have_posts() ) {
    while ( $query_portfolio->have_posts() ) {
      $query_portfolio->the_post();
    }

    // ACF group
    $content = get_field('content');

    ?>

<!-- // ACF field from within group NOT SHOWING -->
<h1><?php echo $content['title']; ?></h1>

<h2><?php the_title(); ?></h2>

    <?php
  } else {
    // no posts found
  }
  
  // Restore original Post Data
  wp_reset_postdata();
?>

Im stuck at this point. Somehow i can not get the Gutenberg Block fields to show within the query on the homepage.

All help is appreciated.

Thanks

0

There are 0 answers