Custom add to cart does not work well only on the first time

You can use the shortcodes provided by WooCommerce. To get the whole button with your custom class and AJAX functionalities.. <?php echo do_shortcode(‘[add_to_cart id=”‘ . get_the_ID() . ‘” class=”add_to_cart_button btn btn-outline-primary btn-lg”]’);?> Or, just the URL to use with your custom button. <a href=”<?php echo do_shortcode(‘[add_to_cart_url id=”‘ . get_the_ID() . ‘”]’);?>” class=”add_to_cart_button btn btn-outline-primary btn-lg”>Přidat … Read more

Set custom post title to read only by user

For gain result custom post titles read-only for all users except the admin, you can use the edit_post capability along with the admin_init hook. add_action(‘admin_init’, ‘restrict_custom_post_title_editing’); function restrict_custom_post_title_editing() { // Check if the current user is not an admin if (!current_user_can(‘administrator’)) { // Get the post types for which you want to restrict title editing … Read more

How do I filter/modify the updated content on save using javascript?

You could start by adding: // What to do here? wp.data.dispatch(‘core/block-editor’).insertDefaultBlock({content:’xxxxxx’}); This will insert a block with the specified text to the end of the blocks list when the user will hit the update button. Once, and then it will self-unsubscribe. To run it every time the user hits the update button, you don’t want … Read more