How to remove fields from woocommerce product admin form? - wordpress

I would like to remove Virtual, Downloadable, Regular Price from Woocommerce product admin form. Any ideas on how to get this to work?

It looks like there is no way to programmatically remove the fields from the woocommerce product admin pages. However you can remove them using CSS.
To do this start by editing the wp admin css, like this (add to functions.php):
add_action('admin_head', 'my_custom_admin_styles');
function my_custom_admin_styles() {
echo '<style>
</style>';
}
Then all you need to get the selectors for the fields you want to remove, the example below removes the 'regular price' field:
add_action('admin_head', 'my_custom_admin_styles');
function my_custom_admin_styles() {
// just add the css selectors below to hide each field as required
echo '<style>
.form-field._regular_price_field { display: none; }
</style>';
}

Related

Hide title in Woocommerce product category page

Maybe this is too easy for you but to me...I can't do it! Guys, I need to hide the title in 2 of my product categories pages in Woocommerce. product-category/cat1 (category id 145) & product-category/cat2 (category id 146)
I tried to achieve that using CSS:
.catid-145 .entry-title {
visibility: hidden;
}
or
.category-145 .entry-title {
visibility: hidden;
}
I know this title is controlled by:
<h1 class="entry-title">Title here</h1>
I need to remove the title text and preserve the space, that's why I'm using "hidden".
Any idea will be highly appreciated. Thank you.
Please try this :
.catid-145 h1.entry-title {
display: none;
}
Adding the following code will remove the page title from Product Category Page :
if(is_product_category())
{
add_filter( 'woocommerce_show_page_title', '__return_false' );
}
Please add the code in functions.php directly to check. Hope this will help you.
Searching how to hide specific category from WooCommerce side bar, this code will help you.
Go to Products> Categories> Click edit on the category you want to remove.
Once category page is open, you can find the category id in the url, copy that id.
WooCommerce hide category from side
Then open the functions.php file under appearance> theme editor.
Just paste the below code at the end and please replace categories id (in italic) with your category id.
add_filter( ‘woocommerce_product_categories_widget_args’, ‘woo_product_cat_widget_args’ );
function woo_product_cat_widget_args( $cat_args ) {
$cat_args[‘exclude’] = array(‘1725’,’1721′,’1719′,’1722′,’1723′,’1724′,’1725′,’1726′);
return $cat_args;
}
https://phpfresh.com/hide-categories-from-woocommerce-sidebar/

Remove page title from Woocommerce shop in Wordpress

i'm trying to remove the page title from my woocommerce shop page. If i use this css the page title is removed from all pages, this is not what i want.
.page-heading h1 {display: none;}
So i started looking for a page-id, but it seems the shop is a post, so i used postid of my page
.postid-15169 .page-heading h1 {display: none;}
but this doesn't work at all
i also tried to put this is my functions.php
add_filter( 'woocommerce_page_title', false);
But this doesn't do anything either. I guess it's not the shop title i'm needing to remove, just the page title.
Any idea what i can do to remove the title for this page only ?
you can find the page here: https://goo.gl/5LNwRR
I added a ccs code:
.page-title-shop h1 {
display: none;
}
It worked for Woocommerce 3.2.x
Instead of using css, you can use woocommerce filter to get the job done.
function wc_hide_page_title()
{
if( !is_shop() ) // is_shop is the conditional tag
return true;
}
add_filter( 'woocommerce_show_page_title', 'wc_hide_page_title' );
You can remove titles from all woocommerce pages. Here is a blog post about this.

how to remove delete option when mouse hover on all users in wordpress?

I am working on a project in wordpress.
In user options, when I select all users it shows a list of all users with edit / delete option. In my project, I want to remove delete option.
What do I need to do for this
Here is a snippet that hides the delete option from user with specific role (administrator in this case)
$role = get_role( 'administrator' ); // This is the user role
$role->remove_cap( 'delete_users' ); // This is the capability you remove
Refer to the codex for more info. Here are the two functions you need to use:
remove_cap()
get_role()
roles and capabilities - https://codex.wordpress.org/Roles_and_Capabilities#delete_users
You could use CSS to hide the delete option from appearing on hover. The following code adds custom styles the Admin area.
add_action('admin_head', 'hide_user_delete_option');
function hide_user_delete_option() {
echo '<style>
.users-php tr:hover .row-actions .delete{
visibility: hidden;
}
</style>';
}

How to hide classes on some pages in WordPress?

How do I hide some CSS classes on some pages in WordPress? Like if I want to hide featured image in blog posts we use:
.single .post-thumbnail {
display:none;
}
I want the class (like .single) for homepage, search page, archives, etc.
You would need to target the page class. If you look at the source code on whatever page you are on, you'll notice the body class include a unique identifier for your page. You can then target that way. See the Codex for a full run-down of page classes.
Home is home, search is search, archives is archive. The homepage won't be single because that's reserved for posts.
You could set custom ones with a filter.
add_filter( 'body_class', 'new_body_class' );
function new_body_class( $classes ) {
if ( is_front_page())
$classes[] = 'custom-class';
return $classes;

Remove Option Tree menu in admin page

I integrated option tree in my template.
I want to hide OptionTree menu item from users. How to remove Option Tree menu item in admin page?
Add this code to your theme's functions.php:
// Remove Option Tree Settings Menu
add_filter( 'ot_show_pages', '__return_false' );
That will remove the Option Tree admin menu.
Here is another solution.
function remove_ot_menu () {
remove_menu_page( "ot-settings" ); } add_action( 'admin_menu', 'remove_ot_menu' );
I know i'm late to the party but since i got to find
a solution (for an old website i restructering) i tought
i might share "a softer" solution.
2 steps
1. We ad the current user id to the admin body class
2. We add a css to hide the menu except for the intended user.
User id in the body class
/*********************************************
** CUSTOM BODY CLASS
*********************************************/
add_filter('admin_body_class', 'custom_admin_body_class');
function custom_admin_body_class($classes){
$cuserid = get_current_user_id();
return $classes. 'user-'.$cuserid;
}
Add the desired css to anytype of css loaded to wp-admin
** replace user-[number] with yours*
.wp-admin:not(.user-1) #toplevel_page_ot-settings {display: none;}
If your not loading any css to wp-admin you can use this
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>.wp-admin:not(.user-1) #toplevel_page_ot-settings {display: none;}</style>';
}

Resources