admin管理员组

文章数量:1122832

I am currently successful at getting the WordPress patterns via the following query:

SELECT * FROM {$wpdb->posts} WHERE post_type = 'wp_block'

Problem is, I realized post_content is empty, except for some patterns added a long time ago.

  1. I checked MyPHPAdmin table, and its empty there, too (logically).

  2. I tried to 'Export (the pattern) as JSON' and the post_content appears beautifully there! I suppose it's not taking it from the DB but wraps the content already rendered in the patterns page and exports the JSON with the content it has in the UI (or there is another table where I can get this post_content from?)

  3. I tried saving the same way another block that hasn't got much logic in it, and saves its post_content perfectly. The main difference I found from the components that save the post_content is that they use a Save component, while the component that has the issue doesn't, since I render it from the server in my index.php:

<?php

/**
 * Register footer block
 */
function footer___register_block()
{
    register_block_type(__DIR__ . '/build', array(
        'render_callback' => 'render_footer_block'
    ));
}
add_action('init', 'footer___register_block');

/**
 * Render callback for the footer block
 *
 * @param array $attributes
 */
function render_footer_block($attributes)
{
    // Start rendering output
    $output = '<footer ' . wp_kses_data(get_block_wrapper_attributes()) . '>';
    // ...Rest of the footer content
    $output .= '</footer>';

    return $output;
}
?>

So, here is my index.js, where save returns null

/**
 * WordPress dependencies
 */
import { registerBlockType } from '@wordpress/blocks';
import { Editor } from './Editor.js';
import metadata from '../block.json';

// Register the block
registerBlockType( metadata.name, {
    edit: Editor,
    save: () => null,
} );

I already tried adding the Save component and render it just like the others that save correctly the post_content, but this doesn't solve it.

  1. I am looking at my wp_posts table in MyPHPAdmin, and seems like the post_content column is blank for posts after May, regardless of the post_type. Maybe it's a bigger issue than just the Patterns?

Any help will be much appreciated! Thank you.

本文标签: postsCan39t saveget Patterns39 postcontent attribute