Get custom category image from menu
Not sure why your object is returning the non-object notice, but you can set the output of get_term_by to OBJECT, ARRAY_A, or ARRAY_N – You’ll want to use ARRAY_A and then access the term ID via $term[‘term_id’].
Not sure why your object is returning the non-object notice, but you can set the output of get_term_by to OBJECT, ARRAY_A, or ARRAY_N – You’ll want to use ARRAY_A and then access the term ID via $term[‘term_id’].
meta_query format and orderby format should be as follows: $args = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘posts_per_page’=> 10, ‘orderby’ => ‘total_sales’, ‘order’ => ‘DESC’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘_featured’, ‘value’ => ‘yes’, ‘compare’ => ‘=’ ), array( ‘key’ => ‘total_sales’, ‘value’ => ’10’, ‘compare’ => ‘>=’ ) ) … Read more
It’s a css issue. You need to edit two selectors. First is the menu width. It’s set to 100% which is why you’re seeing black space. Edit this class below.: .cap-primary-menu .menu > li.menu-full-width .cap-submenu-ddown { padding: 20px 25px 25px; width: 100%; // set this to auto or something smaller than 100% left: 0; border: … Read more
You’re close, syntax is just slightly off. I can’t quite work out how/what terms you need to query for, but this should be the structure of your arguments: $query = new WP_Query( array( ‘post_type’ => ‘product’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, ‘terms’ => $ids_of_product_cat_terms, … Read more
add_action( ‘save_post_product’, ‘create_product’, 10 ); function create_product( $post_id, $post) { // $post_id and $post are required if ( empty( $post_id ) || empty( $post ) ) { return; } // Dont’ save meta boxes for revisions or autosaves if ( defined( ‘DOING_AUTOSAVE’ ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) … Read more
WooCommerce includes several options in the core plugin for sorting your products on the Shop page. However, most people don’t realize that there’s actually an option for WooCommerce custom product sorting. By default, you’re given 6 options: Default Sorting (custom + name) Popularity (sales) Average rating Most recent Sort by price (ascending) Sort by price … Read more
I think that you have made a mistake in the last line. array_push is not doing what you are trying to achieve (check the Manual) same as update_post_meta accepts different arguments. Besides that WooCommerce is storing galleries in simple comma separated list like 1,45,78,34 so you should change the last line update_post_meta($post_id, array_push($post_id, ‘_product_image_gallery’, $id)); … Read more
As you may or may not know any post meta data is stored in a new table, $wpdb->postmeta. This table has four fields: ‘meta_id’ – A unique id for each entry. ‘post_id’ – The ID of the post for this metadata. ‘meta_key’ – The name of the ‘key’. ‘meta_value’ – The value associated with the … Read more
I came across this post looking for a solution for multiple resubmissions due to update_post_meta. Here’s my solution after looking at these posts wordpress get_post_meta check if multiple values set Prevent processing data multiple times in Woocommerce thankyou hook : <?php global $post; $post = $order_id; if ( isset( $_POST[‘submit’] ) ){ echo ‘Update nicht’; … Read more
You should not make changes in the code of WooCommerce plugin. If you want custom functionality, you can make a new plugin using hooks provided by WooCommerce. WordPress provides manage_product_posts_custom_column, using this you can add a custom column to any post type. Also I suggest trying the Admin Columns plugin.