Can’t select my block by clicking on it

When using apiVersion: 2 you must use the new useBlockProps hook to implement standard block behavior for your custom block. In your case you would “tell” the editor to treat your <img> as a block wrapper. This needs to be implemented in Edit and in Save and is explained here in detail: https://make.wordpress.org/core/2020/11/18/block-api-version-2/ Alternatively you … Read more

Create wordpress header with custom logo in between the menu splitting the menu into two equal parts [closed]

After some testing I found the best way is to use a walker. For this example lets say that this is the code that calls our menu wp_nav_menu([ ‘container’ => false, ‘theme_location’ => ‘right-side-top-menu’, ‘walker’ => new Menu_Middle_Logo() ]); Now for our walker, there isn’t an easy way to determine which of the parent menu … Read more

WooCommerce get_price returning wrong price when used via ajax

It’s important to exit the function when using the wp_ajax hooks. Hopefully this fixes it. function get_ticket_price() { $ticketID = $_REQUEST[‘ticketID’]; echo wc_get_product( $ticketID )->get_price(); // Don’t forget to stop execution afterward. wp_die(); } add_action( ‘wp_ajax_get_ticket_price’, ‘get_ticket_price’ ); add_action( ‘wp_ajax_nopriv_get_ticket_price’, ‘get_ticket_price’ );

How to render a time-of-day string like ’16:42′ with a site’s chosen time format?

The trick here is using wp_date() in a peculiar way, giving it the time of day in seconds (as if it were 1970-01-01 16:42:18), then asking for it to be formatted in UTC. $time=”16:42:18″; if ( preg_match( ‘/^\d\d:\d\d:\d\d$/’, $time ) ) { //validate the $time $ts = intval( substr( $time, 0, 2 ) ) * … Read more