Robert Granlund
asked on
Wordpress Filters
Yesterday I asked a very similar question but the answer does not work in this case. I have a Wordpress Website that has a Core Function and I want to change a label inside of the function. I have created my own custom-functions.php file.
The Core Wordpress File is as follows:
The Core Wordpress File is as follows:
public function get_columns(){
$columns = array(
'cb' => '<input type="checkbox" />',
'status' => __( 'Status', 'woocommerce-subscriptions' ),
'title' => __( 'Subscription', 'woocommerce-subscriptions' ),
'user' => __( 'User', 'woocommerce-subscriptions' ),
'order_id' => __( 'Order', 'woocommerce-subscriptions' ),
'start_date' => __( 'Start Date', 'woocommerce-subscriptions' ),
'expiry_date' => __( 'Expiration', 'woocommerce-subscriptions' ),
'end_date' => __( 'End Date', 'woocommerce-subscriptions' ),
'trial_expiry_date' => __( 'Trial End Date', 'woocommerce-subscriptions' ),
'last_payment_date' => __( 'Last Payment', 'woocommerce-subscriptions' ),
'next_payment_date' => __( 'Next Payment', 'woocommerce-subscriptions' ),
'renewal_order_count' => __( 'Renewals', 'woocommerce-subscriptions' ),
);
return $columns;
}
I'm trying to use the manage_edit function but I don't think I have it correct. I want to change the Label 'Order' to 'My Orders':add_filter ( 'manage_edit-get_columns', 'filter_order_id', 11 );
function filter_order_id( $columns) {
$columns['order_id'] = __( 'Policy Number', 'woocommerce-subscriptions' );
return $columns;
}
ASKER
I'm not sure how to re-write my function above to match what you have offered. Can you elaborate just a bit?
I think that what you have already should work
I removed the 'woocommerce-subscriptions ' text domain from the __() function, I doubt that WC has that translated. I also changed the priority, did some digging around in WC and they are using the default, which is 10.
function alter_product_columns($columns) {
$columns['order_id'] = __( 'Policy Number');
return $columns
}
add_filter('manage_edit-product_columns', 'alter_product_columns', 20);
I removed the 'woocommerce-subscriptions
The only real problem with what you had was the hook you were using to call your function, sorry, I may have confused things by adding a lot of extra stuff.
The hook that's important is manage_edit-{$POST_TYPE}_c olumns
WC uses the post type of product
so you replace {$POST_TYPE} with product and the hook becomes manage_edit-product_column s
The hook that's important is manage_edit-{$POST_TYPE}_c
WC uses the post type of product
so you replace {$POST_TYPE} with product and the hook becomes manage_edit-product_column
ASKER
Sorry the following does not work:
What else can I supply to help us determine the issue?
function alter_product_columns($columns) {
$columns['order_id'] = __( 'Policy Number');
return $columns
}
add_filter('manage_edit-product_columns', 'alter_product_columns', 20);
What else can I supply to help us determine the issue?
what is the URL of the page with these columns?
I don't need your site URL, just the part past /wp-admin/
I don't need your site URL, just the part past /wp-admin/
ASKER
Thank you for your continued help:
wp-admin/admin.php?page=su bscription s
wp-admin/admin.php?page=su
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
You may need to set a high priority to override the filter function used in WC, for example I used 99 above. You may need to look into the WC code the see what they are using and just use a bigger number.
The filter for changing columns is in the form:
Open in new window
and the filter for changing the content of columns is:
Open in new window