Remove menu item from sidebar - wordpress

Someone created a menu in wordpress sidebar. I need to remove that permanently. Can anybody say how can we do that? In this image ( the wordpress dashboard image which you going to see when open this link below ) you can see portfolio, careers, team etc. These are the links someone added before and we need to remove. Thanks :)
http://dev.netbramha.in/projects/image/Untitled.pngenter code here

You can remove menu items using action hook.
function remove_dashboard_menus(){
remove_menu_page( 'wpcf7' );
}
add_action( 'admin_menu', 'remove_dashboard_menus' );
remove_menu_page parameter you can pick up from address URL page parameter like this : http://localhost/wpdemo/wp-admin/admin.php?page=wpcf7

If you are using CPT UI plugin, you can open it in your admin and you will find the portolio cpt created there. Just delete from there.
If you are not using CPT UI plugin, you can go to functions.php and remove the code where portfolio code is defined.

In functions.php check add_action() function. You can find these menu items there.

Related

Customise my wordpress site to have the add to cart button appear when someone hovers over the products. I have attached the scree

I have very beginner level understanding of wordpress, woocommerce and elementor. I am still learning a lot of things. I believe that the best way to learn is to imitate. So, I go through various themes and try to imitate their behaviour and appearance using Elementor. But, this particular theme caught my eye. The Add to cart button appears when someone hovers over the product image instead of always being there. Can you guys please help me figure this out or atleast point me in the right direction?
This is how it should look when someone hovers over the images
This is how it looks when the mouse pointer is away
More info
<?php if($available) {?>
Buy now
<?php } ?>
This code solves my problem as expected.
WooCommerce documentation reference
Solution: Add code in your theme's function.php file.
add_action( 'woocommerce_single_product_summary', 'my_extra_button_on_product_page', 30 );
function my_extra_button_on_product_page() {
global $product;
echo 'Add to cart';
}
Solution: Install Custom WooCommerce Add to Cart plugin
Custom WooCommerce Add to Cart Plugin
Solution: You can use hooks with shortcodes:
custom add to cart button
Or create overrides for WooCommerce files in your own template

How to remove footer from some pages dynamicaly using function.php

I am new to wordpress and learning Plugin development, I m creating a custom plugin, which display a list of page-title with check-boxes in admin section and on checking the selected pages footer should be remove from that pages, now I m facing issue with how to remove footer section?
I dont want to remove footer on single page, so custom template can not be used
I dont want to remove footer using css(like display none)
Can anybody help?
You can use Wordpress's remove_action to help remove unwanted php calls. More on that found here
Something like this:
function your__conditional_footer() {
if( is_front_page() )
return;
remove_action( 'theme_before_footer', 'theme_footer_widget_areas' );
}
Mind you, the function arguments are theme dependent.
Hope this points close.

WooCommerce Shop page : Customize sorting dropdown to product categories dropdown

I would like to modify the products sorting on the shop page to product categories filter where the user can select the browse the products of categories from there.
I am a rookie in programming. I checked the WooCommerce directory to find the .php file I should work on. I got some clue it is in archive-product.php but I don't see the code which display the sorting dropdown.
Can anyone give me some clue to achieve this ? Or is there any workaround ? Thanks.
I added this in functions.php :
// remove default sorting dropdown
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
// now add the new dropdown
add_action( 'woocommerce_before_shop_loop', 'add_product_category_dropdown' );
function add_product_category_dropdown(){
print '<span class="woocommerce-ordering">'; // So it takes the same position as the default dropdown
the_widget( 'WC_Widget_Product_Categories', 'dropdown=1' );
print '</span>';
}
The reason you wouldn't see the code is that majority of what is generated by Woocommerce is handled by actions and hooks. In easier terms this means Woocommerce creates functions that spits out content and assigns them to different areas of the website.(For more information on Woocommerce actions and hooks, read here - https://docs.woothemes.com/document/introduction-to-hooks-actions-and-filters/ )
I'd recommend using the plugin below. It does exactly what you seem to be asking for and you can avoid having to play in parts you might not be comfortable with yet.
https://wordpress.org/plugins/yith-woocommerce-ajax-navigation/
Most awesome thing is that it's not one of those plugins that force you to get premium to actually get the desired effect.
I just found the solution few days ago. I use the function of WooCommerce product categories widget on the shop page.
This line of code will output the dropdown of product categories:
<?php the_widget( 'WC_Widget_Product_Categories', 'dropdown=1' ); ?>

How to create a new button in WordPress admin menu

Please tell me how to create a new button here (at the bottom of the dashboard left-hand navigation): http://prntscr.com/6rlbda
This button only needs to transmit one GET parameter.
Thanks.
You can't add a "button" to the menubar, only a standard link (though you can choose the icon.)
Also your question doesn't specify what you actually want the button (or page it links to) to do, but the standard approach is:
add_action( 'admin_menu', 'register_my_menu_item' );
function register_my_menu_item() {
# the add_action ensures this is only run when admin pages are displayed
add_menu_page( 'Example page', 'Example menu', 'manage_options', 'query-string-parameter', 'my_menu_item');
}
function my_menu_item() {
# your new admin page contents (or behaviour go here)
echo 'Hello World!';
}
(This should ideally go in a plugin, but it can also go in your theme's functions.php)
Documentation: https://codex.wordpress.org/Function_Reference/add_menu_page
You will need to add function in the functions.php in your theme, or in a plugin.
The new button will be showed only when the plugin or the theme where you added the code is active.
Please refer to thiscodex pace.
This is the only proper way to do it, as far as I am aware.

why is the <?php wp_head ?> tag creating a top margin at the top of my theme header

Hey people, I've been coming here for a while but just decided to join.
I'm new to php and I'm trying to make a website with WordPress as the CMS.
Anyway, I'm basically making my own theme because I don't want my website to look like a blog, and it's going pretty smoothly so far but theres this huge top margin gap in the browser even when I set margins to 0px.
I tried trial and error and found out that it's being caused by: <?php wp_head(); ?>
It's two different things.
1. wp_head() function
wp_head() is a template tag to print whatever plugin / theme specific function used by wordpress action. Read codex for more detail about it.
2. The admin bar
The top margin, is generated by wordpress's admin bar.
To fix this for logged in users you can do a couple of things:
Disable admin bar from the admin:
Go to admin panel
Users >> User Profile
Uncheck 'when viewing
site' on 'Show Admin Bar'
Remove the admin bar from your theme entirely:
Open your functions.php
Add this to it:
function my_function_admin_bar(){ return false; }
add_filter( 'show_admin_bar' , 'my_function_admin_bar');
Remove only the code which creates the css:
Open your functions.php
Add this to it:
function my_filter_head() { remove_action('wp_head', '_admin_bar_bump_cb'); }
add_action('get_header', 'my_filter_head');
Note: Extensive updates are from #hitautodestruct
you neeed to call wp_footer() in your footer
just insert this line <?php wp_footer();?> into your footer.php file
If you have updated your wordpress install to the latest version.. there seems to be some bug with the admin bar...
were it would produce an inline stylesheet appended to the top of your pages.. causing the margin-top:28px
see here
1 recomendation is to put a new function into your functions.php file located in your theme folder.. this will completly remove the bar, so no users of your theme will have any of the same issues!
function my_function_admin_bar(){
return false;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');
Not sure if this will help.. but worth a shot.. also turning off the admin bar while viewing the front end of the site under your profile page..

Resources