how to execute a function only when i send an order to trash [closed]

It depend if you’re using HPOS or not: If not: function my_custom_function_on_order_trash( $post_id ) { // Get the post type of the trashed item $post_type = get_post_type( $post_id ); // Check if the trashed item is an order if ( ‘shop_order’ === $post_type ) { // Your custom code here } } add_action( ‘wp_trash_post’, ‘my_custom_function_on_order_trash’ … Read more

Draft standard post by ACF Data picker

This code works perfectly! function delete_expired_posts() { $args = array( ‘post_type’ => ‘post’, ‘meta_query’ => array( array( ‘key’ => ‘fecha_borrado’, ‘compare’ => ‘EXISTS’, ), ), ‘posts_per_page’ => -1, ); $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $post_id = get_the_ID(); $acf_date = get_field(‘fecha_borrado’, $post_id); $acf_timestamp = strtotime($acf_date); $current_timestamp = time(); if ($acf_timestamp … Read more

How to add placeholder into comment form textarea?

Use the filter comment_form_fields instead of comment_form_defaults. Also, in the call to str_replace(), remove the =”” from required in both strings. So, your code will become: function custom_comment_form_placeholders( $fields ) { if ( isset( $fields[‘comment’] ) ) { $fields[‘comment’] = str_replace( ‘<textarea id=”comment” name=”comment” cols=”45″ rows=”8″ maxlength=”65525″ required></textarea>’, ‘<textarea id=”comment” name=”comment” cols=”45″ rows=”8″ maxlength=”65525″ required … Read more

How to change the url of the archive page to be inside the custom post type

The has_archive parameter for registering the post type should work (untested): register_post_type( ‘news’, array( … ‘has_archive’ => ‘news/all-news’, ‘rewrite’ => array( ‘slug’ => ‘news’, ‘with_front’ => false, ), ) ); Remember to flush the permalinks by going to Settings > Permalinks and clicking Save button.

UPLOADS constant not working in WordPress Multisite

I think that you’re saying that you have moved your “uploads” directory up a level such that it now exists within your installation root, alongside /wp-includes, wp-config.php, etc.? If so, you likely need to update the rewrite rules in your webserver configuration. By default, a multisite .htaccess configuration has a rule like RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 … Read more

If necessary, how should wp_get_attachment_image() and its parameters be escaped?

TLDR: No parameters need to escaped. The below assumes no third-party code hooked into any filters run by the wp_get_attachment_image() function or sub-function calls: $attachment_id (parameter 1) This is used to get the attachment post and reference it in other functions. This parameter is not used in direct output and thus does not need to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)