echo esc_url( get_permalink($post->ID) + complete the ID’s url

The best approach, from my point of view, is to use add_query_arg() function: $only_conent_url = add_query_arg( array( ‘content-only’ => 1 ), get_permalink( $post->ID ) ); And then you can escape it if you need: esc_url( $only_conent_url ); add_query_arg() takes the URL passed as second paramenter and append a properly formatted query string built from the … Read more

How do I run code every 24 hours?

To run something every 24 hours, you can use the WP Cron system. However, keep in mind: wp-cron is ran/checked after every page load. If nobody visits your site for 2 days no cron jobs can run, it needs visitors to get an opportunity to run Because it needs visitors to the site for the … Read more

Woocommerce – get_items() returns empty array

The solution that was provided here did not work for me. It seems that the order items are assigned to the order after the woocommerce_new_order hook is triggered. I only managed to sort my issues after I changed the hook to woocommerce_checkout_order_processed as per below: add_action( ‘woocommerce_checkout_order_processed’, ‘get_order_items_on_checkout’, 50, 3 ); function get_order_items_on_checkout($order_id, $posted_data, $order){ … Read more

Validate and Sanitize WP REST API Request using WP JSON Schema?

You’re already providing a schema, the parameters in args are their own schemas, but WordPress does not enforce this schema or perform sanitisation/validation by default. You can make WordPress enforce it though by setting the validation and sanitisation callbacks to the following: ‘sanitize_callback’ => ‘rest_sanitize_request_arg’, ‘validate_callback’ => ‘rest_validate_request_arg’, rest_validate_request_arg will look up the parameter in … Read more

How to show every second user different types of banners?

Instead of using the Options API, you’d be better off using the Transients API, however in either case you’ll be polluting the *_options table (even if you use transients with expiration times). I’d possibly recommend using wp-session-manager plugin by EAMann’s which will allow you to use and store $_SESSION data in a dedicated sessions database … Read more

CSS change in woo commerce Place Order Text [closed]

I will try to answer your question. since you know how the text can be changed – let me take it for CSS. View in the browser – The browser is rendering the button like this → <button type=”submit” class=”button alt” name=”woocommerce_checkout_place_order” id=”place_order” value=”Confirm order” data-value=”Confirm order”>Confirm order</button> Now create a folder by the name … Read more

Cant connect to database with php 7.3

Old versions of mysqlnd worked with legacy database passwords. I had to update the database to use more secure password format before the mysqlnd plugin would connect from WordPress 5.0.3 to php 7.3 PHP Warning: mysqli::__construct(): (HY000/2000): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset … Read more

Can’t successfully check if post with title exist in database

You have typing mistake. You are using the double quotation mark instead of single quotation mark at the end of the code post_status = “publish” Please use post_status=”publish” instead of post_status=”publish” and then use double quotation mark at the end of query. And also make sure that dynamic values are correctly entered in the query … Read more