Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with Yoast SEO plugin - Block does not show on frontend if last action was adding the ACF block to the editor #457

Closed
pwkip opened this issue Feb 7, 2021 · 1 comment

Comments

@pwkip
Copy link

pwkip commented Feb 7, 2021

This bug only appears when the Yoast SEO plugin is enabled.

After adding an ACF block to the editor, and immediatly saving the post, the block is not rendered on the frontend.

Awkward work-around: make another change in the editor before clicking update. (For example: add another block, switch the ACF block to visual mode, check any checkbox indise the block.)

Here's an example with a block that has no fields:
Peek 2021-02-08 00-38

This made me wonder, what if I add a block that does have fields. It has the same behaviour. However, any interaction in the block (like checking the checkbox) will make the block render properly on the frontend.

Peek 2021-02-08 00-46

How to reproduce?

Install the latest versions of WP, Yoast SEO and ACF Pro (currently WP 5.6.1 / Yoast 15.7 / ACF Pro 5.9.4)

Add this code to your functions.php

add_action('acf/init', 'my_acf_blocks_init');
function my_acf_blocks_init() {
    // Check function exists.
    if( function_exists('acf_register_block_type') ) {
        // Register a testimonial block.
        acf_register_block_type(array(
            'name'              => 'testimonial',
            'title'             => __('Testimonial'),
            'description'       => __('A custom testimonial block.'),
            'category'          => 'formatting',
            'mode'				=> 'edit',
            'render_callback'   => function() {
                echo '<p>This text should be displayed on the frontend</p>';
            },
        ));
    }
}

Import this ACF field

[
    {
        "key": "group_5ff085f624e26",
        "title": "test",
        "fields": [
            {
                "key": "field_60206e818ea7a",
                "label": "This is an ACF field group",
                "name": "",
                "type": "message",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "message": "",
                "new_lines": "wpautop",
                "esc_html": 0
            },
            {
                "key": "field_60207b1e230b2",
                "label": "Checkbox",
                "name": "checkbox",
                "type": "checkbox",
                "instructions": "",
                "required": 0,
                "conditional_logic": 0,
                "wrapper": {
                    "width": "",
                    "class": "",
                    "id": ""
                },
                "choices": {
                    "yes": "yes"
                },
                "allow_custom": 0,
                "default_value": [],
                "layout": "vertical",
                "toggle": 0,
                "return_format": "value",
                "save_custom": 0
            }
        ],
        "location": [
            [
                {
                    "param": "block",
                    "operator": "==",
                    "value": "acf\/testimonial"
                }
            ]
        ],
        "menu_order": 0,
        "position": "normal",
        "style": "default",
        "label_placement": "top",
        "instruction_placement": "label",
        "hide_on_screen": "",
        "active": true,
        "description": ""
    }
]
@pwkip
Copy link
Author

pwkip commented Feb 8, 2021

Sorry for the duplicate. People landing here. The issues is being tracked here:
Yoast/wordpress-seo#16600

@pwkip pwkip closed this as completed Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant