WordPress Genesis : Move Header and Navigation Menu Above the Wrap - css

I have to Move the Header and Navigation Menu above wrap, I tried following codes but It moves the header only it does not move the Navigation.
/** Reposition header outside main wrap */
remove_action( 'genesis_header', 'genesis_header_markup_open', 5 );
remove_action( 'genesis_header', 'genesis_do_header' );
remove_action( 'genesis_header', 'genesis_header_markup_close', 15 ) ;
add_action( 'genesis_before', 'genesis_header_markup_open', 5 );
add_action( 'genesis_before', 'genesis_do_header' );
add_action( 'genesis_before', 'genesis_header_markup_close', 15 );
/* Reposition the secondary navigation menu */
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_before', 'genesis_do_subnav' );
Can anyone guide me or provide me the correct code ?

Try:
add_action('genesis_before_header', 'genesis_do_subnav');
Instead of:
add_action('genesis_before','genesis_do_subnav');

Related

Remove Header/Footer from cart page Storefront theme

I want to remove header and footer from the cart page in storefront woocommerce theme with the help of custom function or hook.
Can you suggest me which function i should use to achieve this ?
Thanks.
You can do two ways. One is using CSS and another is using hooks. As you particularly asked about hooks then I will provide the code for the hooks.
You need to find out which hooks were used in header and footer of storefront theme. And then in storefront child theme, create a functions.php file (if does not exist, most probably it does exist) and then add the following code:
function remove_header_from_cart(){
if( is_cart() ){
remove_action( 'storefront_page', 'storefront_page_header', 10 );
remove_action( 'storefront_before_content', 'storefront_header_widget_region', 10 );
remove_action( 'storefront_header', 'storefront_header_container', 0);
remove_action( 'storefront_header', 'storefront_skip_links', 5 );
remove_action( 'storefront_header', 'storefront_site_branding', 20 );
remove_action( 'storefront_header', 'storefront_secondary_navigation', 30 );
remove_action( 'storefront_header', 'storefront_product_search', 40 );
remove_action( 'storefront_header', 'storefront_header_container_close', 41 );
remove_action( 'storefront_header', 'storefront_primary_navigation_wrapper', 42 );
remove_action( 'storefront_header', 'storefront_primary_navigation', 50 );
remove_action( 'storefront_header', 'storefront_header_cart', 60 );
remove_action( 'storefront_header', 'storefront_primary_navigation_wrapper_close', 68 );
}
}
add_action('wp_head','remove_header_from_cart');
function remove_footer_from_cart(){
if( is_cart() ){
remove_action( 'storefront_footer', 'storefront_footer_widgets', 10 );
remove_action( 'storefront_footer', 'storefront_credit', 20 );
}
}
add_action('wp_head','remove_footer_from_cart');

Repositioning Genesis Nav not working - Issue with remove_action()

I'm new to Genesis (and stack overflow).
I used the following code to reposition my primary and secondary navs above my header, which worked, however it also left a copy of both navs below the header in it's original place. So basically duplicated my navs :(
// Reposition the primary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_header', 'genesis_do_nav', 12 );
// Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_before_header', 'genesis_do_subnav' );
Any ideas? The test site I'm playing around with is at: http://atelierblanc.pixelboutique.co.uk
Thanks
remove_action() must be called inside a function and cannot be called directly in your plugin or theme.
you may try this :
add_action( 'wp_head', 'remove_my_action' );
function remove_my_action(){
remove_action( 'genesis_after_header', 'genesis_do_nav' );
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
}
you can learn more here :
https://codex.wordpress.org/Function_Reference/remove_action

how to move the WooCommerce Add to Cart button below the product description

I'd like to move the WooCommerce "Add to Basket" / "Add to Cart" button below the product description and extra form fields added by WP Field Factory # this page.
I've tried the following in functions.php without success:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 50 );
and
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 25 );
Use this code in functions.php
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_single_add_to_cart');
Since the description is part of the Tabs section as usual we can try to move the description tabs around the page. Try the below code in your functions page.
function move_product_tabs_override() {
remove_action( 'woocommerce_after_single_product_summary',
'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_single_product_summary',
'woocommerce_output_product_data_tabs', 10 );
remove_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_price', 10 );
}
add_action('init', 'move_product_tabs_override', 5);
You should not try changing button position directly from summary hook like this, because even if you succeed this way, your button might be placed somewhere out of the form which will break your functionality.
Rather than this, you could just modify template files from templates/single-product/add-to-cart/ folder.

How to move a Page title but not a Post title for a Genesis child theme

I asked Studio Press support how to move the page title to a different section of the Genesis framework. They replied with code:
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
add_action( 'genesis_after_header', 'genesis_entry_header_markup_open', 11 );
add_action( 'genesis_after_header', 'genesis_do_post_title', 12 );
add_action( 'genesis_after_header', 'genesis_entry_header_markup_close', 13 );
There's a problem with this, in that it moves both Page titles and Post titles. This means on the Blog page, the Post title is moved into the position of the Page title, and the Post title has the Page title e.g. "News".
My question is: how do I move just the Page title, and not the Post title, using remove_action / add_action...?
Help appreciated.
You have 2 choices:
You can use the code in functions.php with a conditional tag like is_singular('page') See this tutorial
Or add the code to a page.php template file with a opening PHP tag like this:
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
add_action( 'genesis_after_header', 'genesis_entry_header_markup_open', 11 );
add_action( 'genesis_after_header', 'genesis_do_post_title', 12 );
add_action( 'genesis_after_header', 'genesis_entry_header_markup_close', 13 );
genesis();

Remove add to cart button from shortcode in woocommerce

I am implementing a shop that only allows logged in users to view the add to cart buttons.
I have successfully hidden most of them with the following code:
function thread_remove_loop_button(){
if(!is_user_logged_in() ){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
}
}
add_action('init','thread_remove_loop_button');
However, there are still some showing in the New Products & Best seller widgets. Looking at the code, I can see these are calling the shortcode
do_shortcode('[add_to_cart id="'.$product->id.'"]');
What is the best way to amend these so the add to cart button only shows for logged in users. Obviously in the template I can do something along the lines of
if(is_user_logged_in())
echo do_shortcode('[add_to_cart id="'.$product->id.'"]');
}
but it seems like there should be a better way? Along the lines of a hook or something?
add_action('init', 'bbloomer_hide_price_add_cart_not_logged_in');
function bbloomer_hide_price_add_cart_not_logged_in() {
if ( !is_user_logged_in() ) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
add_action( 'woocommerce_single_product_summary', 'bbloomer_print_login_to_see', 31 );
add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_print_login_to_see', 11 );
}
}
function bbloomer_print_login_to_see() {
echo '' . __('Login to see prices', 'theme_name') . '';
}
put this in your plugins/woocommerce/woocommerce.php
it will hide the price and add to cart button and print a statement login to see price
The add to cart template function is pluggable, meaning that if you define a function in your theme with the same name it will override that of WooCommerce.
function woocommerce_template_loop_add_to_cart( $args = array() ) {
if(is_user_logged_in()){
wc_get_template( 'loop/add-to-cart.php' , $args );
}
}
You need to use hook which not affect other code.
add_action('init', 'hide_add_cart_not_logged_in');
function hide_add_cart_not_logged_in() {
if (!is_user_logged_in()) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}
}
that only allows logged in users to view the add to cart button.
Here you can get WooCommerce Action and Filter Hook
-https://docs.woothemes.com/wc-apidocs/hook-docs.html

Resources