wordpress-plugin

How to have more than one “Theme Options” page with OptionTree?

北城以北 提交于 2019-12-10 11:09:58
问题 OptionTree (GitHub) allows to create a " Theme Options " page for themes very simply. How could I extend OptionTree in order to create a " Plugin Options " page for my plugin? Thank you! 回答1: It's actually pretty simple. The following code will create a page under the settings page called Test Page . This is how OptionTree creates its own pages. /** * Hook to register admin pages */ add_action( 'init', 'register_options_pages' ); /** * Registers all the required admin pages. */ function

what is the difference between get_terms and get_the_terms in WordPress ?

依然范特西╮ 提交于 2019-12-10 03:32:08
问题 I need your help. My question is what is the difference between get_terms and get_the_terms in WordPress ? I know that get_the_terms for example give me set of categories that a post attached to them, but really I can't understand what get_terms do and how it different from get_the_terms ? thank you all. 回答1: In the WordPress Codex you can find: For get_the_terms: "Retrieve the terms of the taxonomy that are attached to the post." http://codex.wordpress.org/Function_Reference/get_the_terms

Submitting a form on a custom admin page in wordpress

廉价感情. 提交于 2019-12-10 02:36:33
问题 I created a custom page in the wordpress admin which has a simple file upload field and a submit button. I need to figure out how to submit the page to somewhere it can be processed but can't find anything on the web. Does anyone know what the 'action' needs to be on the form to get it to go to a function or another page where i can process the file? 回答1: use this code snippet: add_action( 'admin_action_wpse10500', 'wpse10500_admin_action' ); function wpse10500_admin_action() { // Do your

Display product post type advanced custom field on recent orders template and admin orders (woocommerce)

元气小坏坏 提交于 2019-12-10 01:01:02
问题 I’m trying to display the fields I have created in the recent order template of WooCommerce and I’m not very knowledgeable in PHP. I have created a field called sessions and registered as a product post type. Once a user purchase a product I want thats customs fields "sessions" values to be displayed in the My account > Recent orders (template). I tried looking for answers and solutions and I seem to be stuck. Here is the customized code of my-order.php template that I have been working on. I

Comment pop up disappears and a “confirm” button appears instead when using facebook like button

本小妞迷上赌 提交于 2019-12-09 15:34:38
问题 I'm trying to include a facebook like button in my wordpress blog with the correspondent opengraph tags to show an image, description, etc. While I was testing it (liking and unliking a lot to check results), after clicking the like button, the comment pop up blinked and then out of the blue a "confirm" link appeared. This is so annoying. I've later researched the issue (after banging my head for a big big while) just to find out it seems to be part of a fb policy applied to suspicious sites

Wordpress Plug-ins: How-to add custom URL Handles

[亡魂溺海] 提交于 2019-12-09 09:23:32
问题 I'm trying to write a Wordpress Plug-in but can't seem to figure out how you would modify how a URL gets handled, so for example: any requests made for: <url>/?myplugin=<pageID> will get handled by a function in my plug-in. I'm sure this is a very simple to do, but I'm pretty new to working with Wordpress and couldn't find it in the documentation. 回答1: add_action('parse_request', 'my_custom_url_handler'); function my_custom_url_handler() { if( isset($_GET['myplugin']) ) { // do something exit

How to make sure changes to a Wordpress plugin won't be lost on plugin update?

烂漫一生 提交于 2019-12-09 07:08:18
问题 I'm pretty sure I've read somewhere that you can actually move the main plugin *.php file to somewhere else (I assume under your theme directory) to have it safe in case you made changes to it and your plugin updates. I tried Google but I can't find anything. Google page with good results will suffice. I've just experienced a situation where my 2 plugins which had its layout changed and accommodated my needs and I want to make sure it doesn't happen again. Apart from having the main file in

Wordpress widget how to only display sub-categories based on selected Parent Category?

痴心易碎 提交于 2019-12-09 06:27:41
问题 I was wondering if anybody know hows to modify the existing category widget to only display the categories within the selected parent category. Example: If my categories are structured like: Computers Laptops Desktops Software Electronics Cameras Audio/Video If somebody is viewing posts in the Computers category I would like the categories widget in the side bar to only display Laptops, Desktops & Software.. Is there a way to get this done? Is anybody familiar of a plugin that maybe do that?

WooCommerce: get and set shipping & billing address's postcode

亡梦爱人 提交于 2019-12-09 05:39:26
问题 How do I set/get the Postcode(Zip-code) in woocommerce? Is there a function for this? ie., can I set the zip code through any function? I would also like to know, how to populate this field with my data(say 546621) if the user is not logged in? 回答1: You can do the following to get/set billing/shipping postcodes, To set the values, $customer = new WC_Customer(); $customer->set_postcode('123456'); //for setting billing postcode $customer->set_shipping_postcode('123456'); //for setting shipping

Detect Visual Composer

♀尐吖头ヾ 提交于 2019-12-09 05:32:28
问题 Is there a way to detect if a WordPress page is using Visual Composer? I have 2 different page templates: Default template for regular pages. Template for visual composer pages. I'm hoping there is a way to detect if a user is using visual composer to build the page instead of relying on the user selecting the visual composer template each time. Is there a way to detect what page is being built and then assign a template based on that? 回答1: Yes, you can detect if visual composer is enabled