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.
I checked MyPHPAdmin table, and its empty there, too (logically).
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?)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 thepost_content
is that they use aSave
component, while the component that has the issue doesn't, since I render it from the server in myindex.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.
- I am looking at my
wp_posts
table in MyPHPAdmin, and seems like thepost_content
column is blank for posts after May, regardless of thepost_type
. Maybe it's a bigger issue than just the Patterns?
Any help will be much appreciated! Thank you.
本文标签: postsCan39t saveget Patterns39 postcontent attribute
版权声明:本文标题:posts - Can't saveget Patterns' `post_content` attribute 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736296266a1929753.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论