block editor – Get postId in a wordpress pattern file?
Question
How can I get post data or just post Id inside of a pattern?
I’ve created the following pattern file:
<?php
/**
* Title: Post link
* Slug: mytheme/post-link
*/
?>
<!-- wp:html -->
<div>
<?php
$id = $postId; //how can I get it????
$post = get_post($postId);
$slug = $post['slug'];
?>
<a href="<?= $slug; ?>">Some Button leading to a post</a>
</div>
<!-- /wp:html -->
0
1 month
2022-12-25T10:52:44-05:00
2022-12-25T10:52:44-05:00 0 Answers
0 views
0
Leave an answer