wordpress-plugin

widget create dynamiclly in wordpress plugin

三世轮回 提交于 2019-12-11 00:10:59
问题 I am writing wordpress plugin. This plugin will create widgets based upon response of API call. My API return an array of some third party site links. So based upon count of array, I have to create widgets. Say, response have 10 entries I have to create 10 widgets based upon response. Currently I am creating 10 classes based on response. But I need to iterate through array and create 10 widgets dynamically. Is there any other way I can accomplish this task? please help. class widget_Mywidget

How to get Advanced Custom Field choice value from another Advance Custom Field?

断了今生、忘了曾经 提交于 2019-12-10 22:15:54
问题 I have created two custom fields using Advanced Custom Field plugin. I want it to behave like when I insert value in one text field, it should be filled in the another field which is a choice field. This image is an example where I am inserting Name value and slug value. I want it to return this. 回答1: To auto populate select fields in ACF, you can use the load_field function - see more here: http://www.advancedcustomfields.com/resources/acfload_field/ So, let's say your select field name was

woocommerce in wordpress return always simple as product type

泄露秘密 提交于 2019-12-10 21:52:08
问题 I try of get the type of a grouped product but woocommerce returns empty or always "simple" if I use WC_Product_Factory. When I use: $the_product = new WC_Product(2886); echo $the_product->product_type; returns empty. When I use WC_Product_Factory: $the_product = new WC_Product(2886); $the_product_factory = new WC_Product_Factory(); $the_product = $the_product_factory->get_product($the_product); echo $the_product->product_type; always returns "simple" I try to use: $the_product = wc_get

How can I set and get the values of a multiple select with the Wordpress settings API for a theme options page?

我只是一个虾纸丫 提交于 2019-12-10 21:12:37
问题 I want to use a 'multiple select field' for a field in the theme option page using settings API. I tried with the below code but unable to save all the selected values, it only saves last one selected. add_action('admin_menu', 'create_theme_options_page'); function create_theme_options_page() { add_options_page('Theme Options', 'Theme Options', 'administrator', 'inc/site-options.php', 'build_options_page'); } add_action('admin_init', 'register_and_build_fields'); function register_and_build

WordPress: Assigning widgets to individual pages

*爱你&永不变心* 提交于 2019-12-10 19:11:17
问题 Are there any plugins or hacks that allow assigning widgets to individual pages? EDIT: Using self-hosted (.org) 2.8.4 An example of use would be: when you're editing a page in the admin, you'd ideally have the ability to assign widgets to that specific page. The default WP behavior is more "all or nothing" in that you assign widgets to the global sidebar and that's it... all pages get the exact same set of widgets... no "per page" assignment of widgets. The Widget Logic plugin essentially

Yoast SEO Plugin not recognising content from the Wordpress Template

倾然丶 夕夏残阳落幕 提交于 2019-12-10 18:21:46
问题 I have developed a Wordpress website recently and used all the contents in the template itself. And all the pages and posts fields of WP admin is empty lacking content. So my content is present in my template and not in the post and pages field. I used Yoast SEO for this website and when checking with pages in WPadmin. No content is recognized and thus my SEO score is very low. But my content is present in the template which will be displayed in live also. Example: I want to optimize home

wordpress: media library issue with polylang plugin

十年热恋 提交于 2019-12-10 16:46:50
问题 I'm developing a website with Wordpress, where i'm using the Polylang plugin to make content for multiple different languages. I'm using Polylang for two languages: Dutch(primary) and English(secondary). When I upload images in Dutch pages, all is well. But when I create an English page, and want to add an image that is already been uploaded, the image library is empty. Anyone got an idea how to get them to appear there? Thanks! 回答1: I found the solution. It is default for the Polylang plugin

Wordpress - adding Featured image to custom Post Type

眉间皱痕 提交于 2019-12-10 14:27:52
问题 I'm trying to add a Featured Image to my theme but not for Posts or Pages - I've created a custom type called Properties (its for an estate agent), so how do I enable Featured Image, as it doesn't appear in the sceen options? Hope someone can help, $property = new Cuztom_Post_Type( 'Property', array( 'supports' => array('title', 'editor') )); 回答1: $property = new Cuztom_Post_Type( 'Property', array( 'supports' => array('title', 'editor', 'thumbnail') )); I appear to have solved my own

Trying To Create New Wordpress Database Table

醉酒当歌 提交于 2019-12-10 13:17:03
问题 Just trying to create a new database table on plugin activation. For the love of life I cannot figure out why this will not work. function super_simple_photo_activate() { global $wpdb; $table_name = $wpdb->prefix."super_simple_photo_options"; if ($wpdb->get_var('SHOW TABLES LIKE '.$table_name) != $table_name) { $sql = 'CREATE TABLE '.$table_name.'( thumbs_max VARCHAR(3), image_max VARCHAR(4), image_quality VARCHAR(3), PRIMARY KEY (id))'; require_once(ABSPATH.'wp-admin/includes/upgrade.php');

Wordpress - Restrict access to plugin only

扶醉桌前 提交于 2019-12-10 11:22:49
问题 I have created a plugin using Wordpress and I would like to create a user account that ONLY has access to this plugin. In other words when the user logs in to the wordpress admin panel this plugin is the only thing they see. 回答1: You can make the menu of the plugin available to the user level's capability. As you can see in WordPress codex, add_options_page('My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options'); 'manage_options' is a capability of an