Created
July 7, 2023 07:53
-
-
Save ibrahim-kardi/ccb671f1deb27e5f2a15680e007f81c7 to your computer and use it in GitHub Desktop.
override specific gutenberg block function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (has_block("gallery", get_the_content())) | |
{ | |
$post_blocks = parse_blocks(get_the_content()); | |
foreach ($post_blocks as $post_block) | |
{ | |
if ("core/gallery" == $post_block["blockName"]) | |
{ | |
$ids = $post_block["attrs"]["ids"]; | |
} | |
} | |
} | |
And this is the button: | |
<button class="gallery" | |
<?php | |
for ($i = 0; $i < count($ids); $i++) { | |
$img_link = wp_get_attachment_image_url($ids[$i], "full"); | |
echo "data-img-" . $i . " = " . $img_link . " "; | |
} | |
?> | |
> | |
Light Box | |
</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment