wordpress-plugin

Adding Custom Post Types to Woocommerce

帅比萌擦擦* 提交于 2019-12-23 14:17:52
问题 Can you please let me know if there is any way to add your own Custom Post Type to Woocommerce and use that instead of using Woocommerce Product? Thank 回答1: You can register a Custom Post Type regardless of WooCommerce. WooCommerce creates a "product" one so you wouldn't need that, but perhaps you want to create an "event" CPT for use with WooCommerce you can do that. CPT Documenation If you are planning on replacing the "product" CPT registered by WC then I would begin to question why are

Adding Custom Post Types to Woocommerce

五迷三道 提交于 2019-12-23 14:17:08
问题 Can you please let me know if there is any way to add your own Custom Post Type to Woocommerce and use that instead of using Woocommerce Product? Thank 回答1: You can register a Custom Post Type regardless of WooCommerce. WooCommerce creates a "product" one so you wouldn't need that, but perhaps you want to create an "event" CPT for use with WooCommerce you can do that. CPT Documenation If you are planning on replacing the "product" CPT registered by WC then I would begin to question why are

How WordPress can list users with specific capabilities

╄→尐↘猪︶ㄣ 提交于 2019-12-23 13:12:15
问题 Is there a way to list only the users that has a specific capability, such us "publish_posts" ? 回答1: You can list users with WP_User_Query, but afaik you can only return different roles, not permissions, maybe that's already what you want! There's also a site where you can see the different roles in the wordpress documentation. 回答2: You can just retrieve all users. Then loop through them in a foreach. Check if the user has a specific capability then push the users to another array and use

Rename and overwrite uploaded files

限于喜欢 提交于 2019-12-23 05:49:22
问题 I use the following code to upload images to Wordpress function custom_upload_name($filename) { $info = pathinfo($filename); $item_id = $_POST['item_id']; $filename = $item_id . '.jpg'; return $filename; } add_filter('sanitize_file_name', 'custom_upload_name', 10); if ( ! function_exists( 'wp_handle_upload' ) ) require_once( ABSPATH . 'wp-admin/includes/file.php' ); $item_id = $_POST['item_id']; $uploadedfile = $_FILES['file']; $image_name = $item_id; $upload_overrides = array( 'test_form' =>

Class autoloader in wordpress plugin

*爱你&永不变心* 提交于 2019-12-23 04:56:17
问题 I want to write a class autoloader to use in a wordpress plugin. This plugin will be installed on multiple sites, and i want to minimize the chance of conflicts with other plugins. The autoloader will be something like this: function __autoload($name) { //some code here } My main issue is, what happens if another class also uses a function like this? I think it will be bound to give problems. What would be the best way to avoid something like that? I am trying to not use namespaces so the

Featured Image Resolution not set

妖精的绣舞 提交于 2019-12-23 04:48:34
问题 I am trying to add code for featured image on different resolution. like thumbnail, medium, large and full. But I wanna look like this type of resolution. e.g 125x125 150x150. 250x250 I am trying this code. but it's not work. <?php $thumb_id = get_post_thumbnail_id(); $thumb_url = wp_get_attachment_image_src($thumb_id,array(300,300), true);?> <a href="<?php echo $thumb_url[0];?>" download="image-300x300" target="_blank">300x300</a> </br> It's show full size of image. 回答1: You need to add

On Woocommerce order complete, activate woosensei course

自古美人都是妖i 提交于 2019-12-23 03:44:11
问题 I'm developing a plugin with Woocommerce and Woosensei I can't seem to get the process working of creating an order programmatically, mark the order completed and activate the woosensei course for that particular person. // create a new checkout instance and order id $checkout = new WC_Checkout(); $this_order_id = $checkout->create_order(); // add some data to the order here // [ ......... ] // execute order $order = new WC_Order($this_order_id); $order->update_status('completed'); $learning

Can WordPress post content be external data (not from the database)

懵懂的女人 提交于 2019-12-23 02:53:31
问题 I am trying to display a page based on some data returned from an external API (Amazon). This data is formatted then, has to be displayed on a page, created on the fly, based on URL querys. I can already do this with shortcodes but this has to be from the query. I see all kinds of info in the codex on returning custom query_posts into the loop from the database. However, I cannot find info getting external data to appear on a page. Is this possible in WordPress? (anything is possible, right?)

Custom text label on Woocommerce shop thumbnail images

跟風遠走 提交于 2019-12-23 01:46:10
问题 Am using a Woocommerce theme for a online shop. Where i do like to display some custom text on top of each thumbnail. Something like the following example. I understand that i have to fiddle with the archive-product.php file. And also i need to style the same. Can someone point me in the right direction. Also is it possible to accomplish the same via Advance Custom Field Plugin? 回答1: You should be able to accomplish this via ACF (Advanced Custom Fields). When you create the custom field you

WooCommerce: Account Password Field in Checkout page

杀马特。学长 韩版系。学妹 提交于 2019-12-22 13:01:55
问题 My main goal is to change the "create an account" checkout to register the email as a username. The easy way I thought of was changing "Account Password" from password to email to override user_login . However, I can't seem to find where the "Password" text box is coming from. I know that this the code I needed under form-billing.php , but I am unsure how only password is showing considering there's a for-loop . <?php foreach ( $checkout->checkout_fields['account'] as $key => $field ) : ?> <