Not sure if this is possible but basically I’m inside a custom post type archive, and I want to grab the contents of a different post by id and put it at the top of my archive. The content I want to grab is solely made up of custom gutenberg blocks that I have created in ACF. I managed to do this elsewhere, but not with ACF gutenberg blocks, only with default ones.
I’m successfully getting the post with get_post, but echoing out the content gives me nothing. I ran parse blocks over the post_content but this gives me an array of text content but no innerHTML (which is what I used to grab the regular wordpress gutenberg blocks in another place) – I need the stuff from the block template as well as just the text – the array returned is just a bit of text and a block id with some field ids inside. Can I use these ids to render my block?
Thanks for your help!
echo apply_filters( 'the_content', get_post_field('post_content', $id ) );
Replace $id with the ID of the post with the blocks you want to include. I’ve created a “header” and “footer” custom post types which I use solely for storing specific blocks I designed for said parts (which basically allows me to grab the desired “header” and “footer” posts/blocks from wherever I want).
Thank you! That is ideal, works perfectly!
How would you implement this inside a custom post type loop? I keep getting null for any ACF values from the custom gutenberg block.