有没有办法在"添加新帖子"页面的自定义字段下拉列表中添加自定义字段键而不添加字段?
我想隐藏我的编辑帖子自定义字段区域中的某个元键.假设我有名为"test1"的元键.我不希望它出现在我的编辑帖子/页面上.但是,我仍然希望显示其他自定义字段,例如让我们说"test2""test3""test4"等.
我读过有关remove_meta_box('postcustom','post','normal')的内容,但它隐藏了我所有的自定义字段.
我也读过有关使用"_test1"重命名元键的内容.是的,它是隐藏的,但问题出现了,因为有一个插件使用该元键("test1").因此,重命名元键以下划线开头并不是一个好主意.
是否有任何代码/功能可以隐藏某些自定义字段?我不希望用户编辑"test1"自定义字段,但他们仍然可以编辑其他自定义字段.
谢谢!
这是我目前的查询:
query_posts(array_merge(array('tag' => $pagetag,'meta_key'=>priority,'orderby' =>meta_value, 'order' =>'ASC','paged' => get_query_var('paged'))));
Run Code Online (Sandbox Code Playgroud)
我的问题是查询只显示了我的'meta_key'值的帖子,这意味着'priority'不是NULL.如何改进此查询以使其仍然可以通过我的meta_key排序,但是还会显示所有非NULL的帖子?
提前致谢!
:我已经加入和已经使用USERMETA场(称为user_custom_hash从)wp_usermeta表.意味着我已经Insert/ Edit/ Deleting某处某处的代码字段.
不需要在之前显示出来.
所以现在......
USERMETA在Wordpress管理控制台的用户配置文件页面上显示此字段?(我的意思是管理员仪表板上的"编辑用户"页面.)例如:
Custom Hash Key: __239cc68ba2423ddf67dcfcd4aa2fa83b__我的意思是,要在这里的某个地方展示:

Note:
Wordpress Version currently: 3.5.0
我使用PODS.io Wordpress插件为用户元创建了以下自定义字段:
我通过在我的主题中使用以下代码,在额外信息下将这些字段添加到WooCommerce结帐functions.php:
add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );
function my_custom_checkout_field( $checkout ) {
woocommerce_form_field( 'date_of_birth', array(
'type' => 'text',
'class' => array('my-field-class form-row-wide'),
'label' => __('Date of Birth'),
'placeholder' => __('dd/mm/yyyy'),
), $checkout->get_value( 'date_of_birth' ));
woocommerce_form_field( 'emergency_contact_name', array(
'type' => 'text',
'class' => array('my-field-class form-row-wide'),
'label' => __('Emergency Contact Name'),
'placeholder' => __('contact name'),
), $checkout->get_value( 'emergency_contact_name' ));
woocommerce_form_field( 'relation', array(
'type' => 'text',
'class' => array('my-field-class form-row-wide'),
'label' => __('Emergency Relation'),
'placeholder' => …Run Code Online (Sandbox Code Playgroud) 我正在定制WooCommerce,我想在产品页面中添加和显示自定义文本(条件和品牌).
该头寸位于"库存"或"SKU"元下.我已设法创建并保存自定义字段,但如何将这些元值打印到产品页面.
请帮忙!
这是我的代码functions.php:
// Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
// Text Field
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
woocommerce_wp_text_input(
array(
'id' => '_conditions',
'label' => __( 'Conditions', 'woocommerce' ),
'placeholder' => 'i.e: brand-new; refurbished; defected...',
'desc_tip' => 'true',
'description' => __( 'Enter the conditions of the products here.', 'woocommerce' )
)
);
echo '</div>';
woocommerce_wp_text_input(
array(
'id' => '_bands',
'label' => __( 'Brands', 'woocommerce' ),
'placeholder' => 'i.e: Lacoste; Hugo Boss...etc',
'desc_tip' => …Run Code Online (Sandbox Code Playgroud) 我有添加到购物车的问题.我有一个产品有不同的自定义条件可供选择.当客户选择特定选择时.它增加了购物车.当客户选择另一个选择并添加.它显示为购物车中的第二个项目.哪个没关系.但在付款后,订单会显示项目1和项目2下的自定义选项,而不显示自定义数据.
所以我在思考而不是展示与不同产品相同的产品.我想更新产品自定义数据,因此它将始终显示为单个项目.
(注意:我已经从管理员启用了"单独销售"选项,但其工作正常).
如果没有,你可以告诉我如何正确显示订单,所以付款后发送的电子邮件,订单页面将正确显示.
注意:我使用的自定义数据是loc和date.
先感谢您.
与供应商(WC供应商)一起开发WooCommerce网上商店.
我需要显示我在供应商资料中创建的自定义字段.它应显示在项目和供应商名称下order-details.php.
如何按卖家/供应商ID显示个人资料字段?
有人可以帮帮我吗?
这是我将要撒谎的屏幕截图:
配置自定义字段
向用户个人资料页面添加自定义字段
add_action( 'show_user_profile', 'wp_added_user_profile_fields' );
function wp_added_user_profile_fields( $user ) {
?>
<table class="form-table">
<tr>
<th><label for="billing_enumber"><?php _e( "eNumber", 'woocommerce' ); ?></label></th>
<td>
<input type="text"
name="billing_enumber"
id="billing_enumber"
class="regular-text"
value="<?php echo esc_attr( get_the_author_meta( 'billing_enumber', $user->ID ) ); ?>"/>
<span class="description"><?php _e( 'Please enter your eNumber.', 'woocommerce' ); ?></span>
</td>
</tr>
</table>
<?php
}
Run Code Online (Sandbox Code Playgroud)
将更新功能添加到用户配置文件的自定义字段
add_action( 'edit_user_profile', 'wp_added_user_profile_fields' );
function wp_save_added_user_profile_fields( $user_id ) {
if ( current_user_can( 'edit_user', $user_id ) ) {
update_user_meta( $user_id, 'billing_enumber', …Run Code Online (Sandbox Code Playgroud) 我正在尝试在产品注释(WooComerce 3+)中添加“电话”字段。*也适用于未注册的用户(访客)。电话号码只能由管理员在管理面板中查看。
*电话字段需要设为“ 必填 ”。
我尝试使用此代码,但这不起作用:
function true_phone_number_field( $fields ) {
$fields['phone'] = '<p class="comment-form-phone"><label for="phone">Phone</label> <input id="phone" name="phone" type="text" value="" size="30" /></p>';
}
add_filter( 'comment_form_default_fields', 'true_phone_number_field');
Run Code Online (Sandbox Code Playgroud) 我有一个代码,显示产品编辑页面上的复选框。当我单击此复选框时,单个产品页面上将显示一个选择框。
这是我的代码:
// Display Checkbox Field
add_action('woocommerce_product_options_general_product_data', 'roast_custom_field_add');
function roast_custom_field_add(){
global $post;
// Checkbox
woocommerce_wp_checkbox(
array(
'id' => '_roast_checkbox',
'label' => __('Roast Level', 'woocommerce' ),
'description' => __( 'Enable roast level!', 'woocommerce' )
)
);
}
// Save Checkbox Field
add_action('woocommerce_process_product_meta', 'roast_custom_field_save');
function roast_custom_field_save($post_id){
// Custom Product Checkbox Field
$roast_checkbox = isset( $_POST['_roast_checkbox'] ) ? 'yes' : 'no';
update_post_meta($post_id, '_roast_checkbox', esc_attr( $roast_checkbox ));
}
// Display Select Box
add_action( 'woocommerce_before_add_to_cart_button', 'add_roast_custom_field', 0 );
function add_roast_custom_field() {
global $post;
// If …Run Code Online (Sandbox Code Playgroud)