Repositioning Genesis Nav not working - Issue with remove_action() - wordpress

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

Related

Remove the Sort by dropdown completely, in WooCommerce

I want to remove the Sort by dropdown completely, in my WooCommerce installation.
http://cswpstage.hostworks.net/product-category/memorabilia/signed-photos/
Thanks!
It depends on the theme that you're using. There are two approaches, CSS and PHP.
I see on your theme you have already hidden it via CSS using
.sort-param-order,
.sort-param-sort {
display: none;
}
If you want to hide it with PHP, you need to look for the action which adds it and remove that action. A search for woocommerce_catalog_ordering will generally return the action you're looking for.
Here is how you remove it via standard WooCommerce:
<?php
/**
* Remove sorting from WooCommerce.
*/
function thenga_remove_filtering() {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
}
add_action( 'init', 'thenga_remove_filtering' );
And here is how you remove it from the Storefront theme:
<?php
/**
* Remove sorting from Storefront.
*/
function thenga_remove_filtering() {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
}
add_action( 'init', 'thenga_remove_filtering' );

Moving Woocommerce Order Review to Top of Checkout

I'm trying to move the order review section to the top of Woocommerce checkout page and this is working:
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
add_action( 'woocommerce_before_checkout_form', 'woocommerce_order_review', 20 );
But when Checkout opens it scrolls down to the order review section, rather than to the top of the page.
This works:
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
add_action( 'woocommerce_after_checkout_billing_form', 'woocommerce_order_review', 20 );
Moving the review form doesn't automatically move the Your Order heading. This is what I added to functions.php
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
add_action( 'woocommerce_before_checkout_form', 'prefix_wc_order_review_heading', 3 );
add_action( 'woocommerce_before_checkout_form', 'woocommerce_order_review', 4 );
/**
* Add a heading for order review on checkout page.
* This replaces the heading added by WooCommerce since order review is moved to the top of the checkout page.
*/
function prefix_wc_order_review_heading() {
echo '<h3>Your Order</h3>';
}
And to hide the existing Your Order heading (and some spacing for the credit card form), I added this to style.css
.woocommerce-checkout #order_review_heading {
display: none !important;
}
.woocommerce-checkout #order_review {
margin-top: 2rem !important;
}

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();

How To Move Product Variation Descriptions in WooCommerce

I'd like to move my product's variation descriptions in Woocommerce beneath the add to cart button, and I can't find what hook I'm supposed to use. These are the variation's custom descriptions that load on selection in AJAX.
I'm able to hook another custom function beneath the add to cart button. So I think my problem is not knowing the name of the hook and/or if it's a hook versus a filter. I think it's either woocommerce_before_single_variation or woocommerce_before_add_to_cart_button.
Here's several attempts I've tried before with no luck in functions.php:
remove_action( 'woocommerce_after_single_variation','woocommerce_single_product_summary', 20 );
add_action( 'woocommerce_after_single_variation', 'woocommerce_single_product_summary', 9 );
//try #2
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
add_action('woocommerce_after_add_to_cart_button', 'woocommerce_single_variation', 35);
Thank you!
The functionality I was looking for is included in WooCommerce 2.4 as a default but is not done on a hook. It's added by jQuery updating a div instead - which I found in woocommerce/js/assets/frontend/add-to-cart-variation.js. So I moved the div's location instead:
add_action ('woocommerce_after_single_variation', 'move_descriptions', 50);
function move_descriptions() {
?>
<div class="woocommerce-variation-description" style="border: 1px solid transparent; height: auto;"></div>
<?php
}
I think this will do,
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
add_action('woocommerce_after_add_to_cart_form', 'woocommerce_template_single_excerpt');
Only move Short description if product is variable
add_action('wp_head', 'move_short_desc_for_varition');
function move_short_desc_for_varition() {
#
global $post;
$product = get_product( $post->ID );
if( $product->is_type( 'variable' ) ){
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
add_action('woocommerce_after_add_to_cart_form', 'woocommerce_template_single_excerpt');
}
}
The problem is in the priority of the remove hook.
I give you an example (this work for me):
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 15 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 10 );
Pay attention and try with differents priorities.

WordPress Genesis : Move Header and Navigation Menu Above the Wrap

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');

Resources