BASIC

Content

What is Block Content?

The Content file (also known as render.php in WordPress) is the heart of your block – the actual markup and logic that determines what visitors see on your website when they view a page containing your block. This is where you define the HTML structure, dynamic content, and data output that gets rendered on the frontend.

Writing Your Block Content

You have complete flexibility in how you write your block’s content. FanCoolo supports both plain HTML and dynamic PHP, giving you the power to create anything from simple static blocks to complex, data-driven components.

Plain HTML

If your block doesn’t need any dynamic behavior, you can write standard HTML markup:

<div class="my-block">
    <h2>Welcome to My Block</h2>
    <p>This is a simple static block with hardcoded content.</p>
    <button class="btn">Click Me</button>
</div>

PHP with HTML

Mix PHP with HTML to create dynamic, customizable content:

<div class="my-block">
    <h2><?php echo esc_html($attributes['heading']); ?></h2>
    <p><?php echo esc_html($attributes['description']); ?></p>

    <?php if ($attributes['showButton']) : ?>
        <a href="<?php echo esc_url($attributes['buttonUrl']); ?>" class="btn">
            <?php echo esc_html($attributes['buttonText']); ?>
        </a>
    <?php endif; ?>
</div>

Using Block Attributes (Custom Fields)

Attributes are the custom fields you define in the Attributes Manager. They allow content editors to customize each instance of your block without touching code.

Accessing Attributes

All your block’s attributes are available through the $attributes array:

<div class="hero-section">
    <h1><?php echo esc_html($attributes['heading']); ?></h1>
    <p class="subtitle"><?php echo esc_html($attributes['subtitle']); ?></p>
</div>

Attribute Variables

Every attribute is also available as its own PHP variable, named after the attribute in snake_case. heading becomes $heading and buttonUrl becomes $button_url:

<div class="hero-section">
    <h1><?php echo esc_html($heading); ?></h1>
    <a href="<?php echo esc_url($button_url); ?>">Read more</a>
</div>

If the attribute has no value, the variable holds its default, so you don't need extra checks. Existing $attributes['…'] code keeps working. See Attributes Manager for the naming rules and reserved names.

Inserting Attributes with Autocomplete

Type $att in the Content editor to get one suggestion per attribute, such as $attributes:heading. Pick one to insert the same code the Attributes tab shows for that attribute. Inside <?php … ?> the code goes in without its own PHP tags. The suggestions follow the Attributes tab, so a new attribute is suggested before you save.

Including Symbols

Symbols are reusable components like icons, logos, or repeated design elements that you can include in your blocks. This makes it easy to maintain consistent design elements across your site.

You include symbols using a self-closing tag syntax with the symbol name.

Basic Symbol Usage

<div class="card">
    <CompanyLogo />
    <h3><?php echo esc_html($attributes['title']); ?></h3>
    <p><?php echo esc_html($attributes['description']); ?></p>
</div>

Multiple Symbols

<div class="social-share">
    <h4>Share this post:</h4>
    <FacebookIcon />
    <TwitterIcon />
    <LinkedinIcon />
</div>

Conditional Symbols

<div class="status-indicator">
    <?php if ($attributes['status'] === 'success') : ?>
        <CheckIcon />
    <?php else : ?>
        <WarningIcon />
    <?php endif; ?>
    <span><?php echo esc_html($attributes['message']); ?></span>
</div>

Symbols in Loops

<div class="rating">
    <?php for ($i = 0; $i < intval($attributes['rating']); $i++) : ?>
        <StarIcon />
    <?php endfor; ?>
</div>

Reference Warnings

The Content editor underlines references that point at something that no longer exists. Hover the squiggle to read the message.

Message Meaning and fix
Symbol <Name> not found No symbol has this name. Fix the tag name or create the symbol.
<Name> has no attribute "x" The symbol does not define x. Remove it from the tag, or add it to the symbol.
Block attribute "x" was deleted A symbol tag passes $attributes['x'], but the block has no attribute x. Re-create the attribute or pick another one for the tag.
$attributes['x'] does not work in a symbol Symbols have no block attributes. Use the symbol's own attributes.
Unknown WordPress value "x" $wp['x'] is not a known WordPress value. Pick a valid one from WordPress values in the Symbol Attributes dropdown.
$x is not defined by any attribute (it is null) No attribute generates $x. Add the attribute or remove the variable.

After Save, a warning toast reads "Saved. N reference warnings — see the marked lines." Saving always succeeds, so warnings are a prompt to check, not an error. Symbol tags show the same problems in the Symbol Attributes panel, see Symbol.

Built-in Error Prevention & Validation

FanCoolo includes intelligent error prevention to protect your site from broken code. This safety system ensures that only valid, working code makes it to your live site.

PHP Syntax Validation

Before generating your block’s render.php file, FanCoolo automatically validates that your PHP code is syntactically correct. This happens every time you save your block.

What gets validated:

  • PHP syntax errors (missing semicolons, unclosed brackets, etc.)
  • Invalid PHP tags
  • Function/variable naming issues
  • Parse errors

Safe File Generation

Only valid PHP code will be generated as a block file. If your code contains errors, the file generation process will be blocked and you’ll receive clear error messages.

Protection you get:

  • Prevents broken blocks from appearing in Gutenberg
  • Stops PHP fatal errors from reaching your live site
  • Ensures your blocks always work correctly
  • Protects your content editors from encountering errors

Clear Error Messages

When validation fails, you’ll receive helpful, actionable error messages that include:

Line Number: The exact line where the error occurred. The generated render.php holds only your template, so when PHP reports an error on line 15 of render.php, that is line 15 in the Content editor.

Error on line 15: Unexpected token ')'

Error Type: What kind of error was detected

Parse Error: syntax error, unexpected ')', expecting ';'

Context: Information to help you understand and fix the problem

You may have a missing semicolon on the previous line, or an extra closing parenthesis.