admin管理员组

文章数量:1279117

Before Gutenberg I added meta_fields like "_my_integer_value" and added them to the post. I could query with something like this:

$args = array(
    'post_type'      => 'post',
    'orderby'        => array( 'meta_value_num' => 'DESC', 'date' => 'DESC' ),
    'meta_key'       => '_my_integer_value',
    'posts_per_page' => '300',
    'order'          => 'DESC'
);

Now I made a block that saves its content to the html of the block.

block.json

"attributes": {
    "my_integer_value": {
        "type": "string",
        "source": "html",
        "selector": "span.value",
        "default": 5
    }
},

What is the best practice to use blocks and make information in them sortable in queries? Can I save the contents to the post meta somehow? Is there another option to save content in block that can be queried? This allows only for queries for posts that have this block but I can't sort them: WP Query by Gutenberg block and get its attribute

本文标签: Gutenberg Block Query for posts with blocks and sort by attributes