add category id to option name when adding an option on edit_category

There are 4 problems a small one, a security problem, a misunderstanding, and a big problem. The Small Problem Because you used [] notation in the name you’ve indicated that there are multiple category_meta_ values: category_meta_[<?php echo $cat->term_id ?>] Which means $_POST[‘category_meta_’] will always be an array. It would be much easier to append the … Read more

How to prepend a header section to all pages related to my WordPress Plugin

it didn’t work for you because hook admin_head is designed to add <link> tags inside <head> section. So even if you will render something there it won’t be visible, because it is outside <body>. If you want to render something after admin head bar, you should use wp_after_admin_bar_render hook: https://developer.wordpress.org/reference/hooks/wp_after_admin_bar_render/ To determine if you are … Read more

How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false

The simplest solution would be to query all posts using a -1 in place of the 12 in your ‘posts_per_page’ argument of your query. Then use a counter that ticks up if all of the above conditions equal true. $args = array( ‘post_type’ => $post_slug, ‘posts_per_page’ => -1, ‘paged’ => 1, ‘post_status’ => ‘publish’, ); … Read more

How to disable block directory?

Yes, it is possible. Excerpt from Editor Hooks → Block Directory in the block editor handbook: The Block Directory enables installing new block plugins from WordPress.org. It can be disabled by removing the actions that enqueue it. In WordPress core, the function is wp_enqueue_editor_block_directory_assets. To remove the feature, use remove_action, like this: <?php // my-plugin.php … Read more

How to set the margin on an innerBlock in a block variation?

If we create a paragraph and give it a margin of 2 ( default settings no custom scales or theme.json ) then we get this: <!– wp:paragraph {“style”:{“spacing”:{“margin”:{“top”:”var:preset|spacing|30″,”right”:”var:preset|spacing|30″,”bottom”:”var:preset|spacing|30″,”left”:”var:preset|spacing|30″}}}} –> <p style=”margin-top:var(–wp–preset–spacing–30);margin-right:var(–wp–preset–spacing–30);margin-bottom:var(–wp–preset–spacing–30);margin-left:var(–wp–preset–spacing–30)”>stuff</p> <!– /wp:paragraph –> It sounds reasonable to extract var(–wp–preset–spacing–30) from the style attribute but this wouldn’t be right, as that’s generated HTML. Instead we … Read more