Support

Account

Home Forums Gutenberg How to make a ACF Block default and mandatory for a specific post type

Solving

How to make a ACF Block default and mandatory for a specific post type

  • Hello All,

    So I made this new Hero Block for a site that I’m working on, and I’m trying to figure out how to make it default and always present in a specific post type – in this case, the “accommodations” post type. Basically, I want this block to show up every time I make a new post in that post type, preferably right at the top. But honestly, I have no idea if that’s even possible! I’ve tried editing the block.json file and even tinkering with the functions.php, but I haven’t gotten any results.

    Does anyone know if this is possible? Any help would be much appreciated!

    Thanks a lot

    
    {
      "name": "acf/hero",
      "title": "Ferienpark Hero",
      "description": "Hero Block",
      "style": ["file:./hero.css"],
      "category": "Ferienpark",
      "icon": "cover-image",
      "keywords": ["hero", "header", "image"],
      "supports": {
        "align": true,
        "anchor": true,
        "html": true,
        "post_types": ["accommodations"],
        "default": true
      },
    
      "acf": {
        "mode": "edit",
        "renderTemplate": "hero.php"
      }
    }
    
  • UPDATE:

    changed the line “post_types”: [“accommodations”], to “postTypes”: [“accommodations”], as I could find in the documentation, still no success.

  • Hey @ramate

    To achieve what you’re after, my understanding is you would need to setup a block template. Check out these resources:

    Hope this steers you in the right direction 👍

  • @cubes 2048 Umm, I have never seen this problem before. Maybe I will refer some documents and answer @ramate later.

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

You must be logged in to reply to this topic.