Programmatically add and remove woocommerce product category

Add the codes below to a custom plugin To add the category to new products function set_new_product_cat( $post_id, $post, $update ) { if(“product” === $post->post_type){ // Exit out as we are updating an existing product if ( $update ) { return; } //Appends the category 35 to the product wp_set_post_categories( $post->ID, 35, true); } } … Read more

Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false

I noticed in your comment… Return the uploaded image ID, so to use to update the ACF field Here is two functions which may help you out… gf_handle_attachments() to handle converting gform submission image file into wordpress media attachment. Returning media (attachment) id. gf_upload_to_media_acf() to handle gform submitted image or multiple images and update defined … Read more

add mediaelement.js plugins into WordPress video player control bar

You can alter the mediaelement.js feature-set using the mejs_settings hook. Settings Overview Defaults are: playpause, current, progress, duration, tracks, volume, fullscreen. Add the plugin to the array as needed to extend the features. add_filter(‘mejs_settings’, function ($settings) { $settings[‘features’] = array(…,’jumpforward’); return $settings; }); Make sure to enqueue the plugin itself: wp_enqueue_script( ‘mejs-plugin-name’, ‘path_to_plugin_file’, array(‘wp-mediaelement’), null, … Read more

How Display Posts on category

You should look at the WordPress Template Hierarchy. If you want to show an archive of your posts you create a template called archive-mahsulat.php where mahsulat is your post type. Then you can add a normal WordPress Loop to the file so it can output posts of that type. If you’re looking to create a … Read more

Simple Plugin with custom javascript wont work – no console error

You could “borrow” the html form from the example and include this in your template – either directly of via a filter like wp_footer: <form method=”GET” action=”/javascript/search-highlight/” onsubmit=”myHilitor.apply(hilite.value); return false;”> <fieldset> <legend>Highlight Words</legend> <label>Keywords</label><span><input type=”text” size=”32″ name=”hilite” value=”search engine keywords”> <input type=”submit” value=”Apply”> <input type=”button” value=”Remove” onclick=”myHilitor.remove();”></span> </fieldset> </form>

How do I display a user’s previous orders as a select box option on a product?

You can try something like this: add_action( ‘woocommerce_before_add_to_cart_form’, ‘add_list_completed_orders’ ); function add_list_completed_orders() { // get orders $orders = wc_get_orders ( array ( ‘status’ => array( ‘wc-completed’ ), ‘type’ => ‘shop_order’, ‘limit’ => -1, ‘return’ => ‘ids’, ‘customer_id’ => get_current_user_id(), ) ); if ( ! empty( $orders ) ) { // set value options $options=””; foreach … Read more