Robert Granlund
asked on
Wordpress Filters
I have attempted to ask this question before but I don't think I was being clear enough and I also know just enough to make me dangerous!
I want to create a Wordpress Filter to change a line of code within a Core Function in Wordpress / Woocommerce.
The Worpress / WooCommerce function is as follows:
Here is what I have that is not working. (This filter is my Custon-Functions.php file)
I want to create a Wordpress Filter to change a line of code within a Core Function in Wordpress / Woocommerce.
The Worpress / WooCommerce function is as follows:
public function edit_columns( $existing_columns ) {
$columns = array();
$columns['cb'] = '<input type="checkbox" />';
$columns['order_status'] = '<span class="status_head tips" data-tip="' . esc_attr__( 'Status', 'woocommerce' ) . '">' . esc_attr__( 'Status', 'woocommerce' ) . '</span>';
$columns['order_title'] = __( 'Order', 'woocommerce' );
$columns['order_items'] = __( 'Purchased', 'woocommerce' );
$columns['shipping_address'] = __( 'Ship to', 'woocommerce' );
return $columns;
}
I have followed the directions offered by Wordpress but it is not working for me. I want to Replace The Word "Order" with the words "My Number" on line: 6Here is what I have that is not working. (This filter is my Custon-Functions.php file)
function filterAdminLabels( $existing_columns ) {
$labels = array('Order');
$existing_columns = str_ireplace($labels, 'My Number', $existing_columns);
}
add_filter ( 'edit_columns', 'filterAdminLabels', 2 );
ASKER
I tried that and nothing Changed. However, I did discover I was trying to hook into the wrong function. Here is the correct function and I want to replace the word Order with My Policy:
Wordpress Function
I followed the instructions but nothing happens. What do you think I am doing wrong?
Wordpress Function
public function shop_order_columns( $existing_columns ) {
$columns = array();
$columns['cb'] = '<input type="checkbox" />';
$columns['order_status'] = '<span class="status_head tips" data-tip="' . esc_attr__( 'Status', 'woocommerce' ) . '">' . esc_attr__( 'Status', 'woocommerce' ) . '</span>';
$columns['order_title'] = __( 'Order', 'woocommerce' );
$columns['order_items'] = __( 'Purchased', 'woocommerce' );
$columns['shipping_address'] = __( 'Ship to', 'woocommerce' );
$columns['customer_message'] = '<span class="notes_head tips" data-tip="' . esc_attr__( 'Customer Message', 'woocommerce' ) . '">' . esc_attr__( 'Customer Message', 'woocommerce' ) . '</span>';
$columns['order_notes'] = '<span class="order-notes_head tips" data-tip="' . esc_attr__( 'Order Notes', 'woocommerce' ) . '">' . esc_attr__( 'Order Notes', 'woocommerce' ) . '</span>';
$columns['order_date'] = __( 'Date', 'woocommerce' );
$columns['order_total'] = __( 'Total', 'woocommerce' );
$columns['order_actions'] = __( 'Actions', 'woocommerce' );
return $columns;
}
My Function:function filterAdminLabels( $existing_columns ) {
$labels = array('Order');
$existing_columns = str_ireplace($labels, 'Policy Number', $existing_columns);
return $existing_columns;
}
add_filter ( 'shop_order_columns', 'filterAdminLabels', 2 );
I followed the instructions but nothing happens. What do you think I am doing wrong?
I think you should use the filter: 'manage_edit-shop_order_co lumns'
ASKER
I don't understand, please explain
add_filter ( 'manage_edit-shop_order_co lumns', 'filterAdminLabels', 2 );
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
WOW! Thanks for pointing out the filter. Very powerful. Thanks so much for taking the time to answer that question. i have been working on this issue for almost 6 hours!
Open in new window
after the line:Open in new window