remove woocommerce storefront homepage title php - php

I am using storefront theme by woocommerce. I need to remove homepage title (h1) with php, i know css solution, but i don't want to use it, because i want to add h1 to other place in that page and it's bad for seo to have 2 h1's in one page! I also know about plugins that remove page title, but they are working as css display:none; property!
I tried all the snippets that i could find in web, but no luck!
Here is my site domain BrightBells.com
Here is PHP code snippets that i tried one by one by adding to my functions.php file, but none of its help!
Snippet 1
function wc_hide_page_title() {
if( is_front_page() )
return true;
}
add_filter( 'woocommerce_show_page_title', 'wc_hide_page_title' );
Snippet 2
function sf_change_homepage_title( $args ) {
remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
add_action( 'init', 'sf_change_homepage_title' );
Snippet 3
function sf_change_homepage_title( $args ) {
remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
add_action( 'wp', 'sf_change_homepage_title' );
Snippet 4
function sf_change_homepage_title( $args ) {
remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
add_action( 'after_setup_theme', 'sf_change_homepage_title' );
Snippet 5
function sf_change_homepage_title( $args ) {
if(is_front_page()) {
remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
}
add_action( 'init', 'sf_change_homepage_title' );
Snippet 6
if ( is_front_page() ) {
remove_action( 'storefront_page', 'storefront_page_header' );
}
Snippet 7
if ( is_page('page id') )
{
add_filter( 'the_title', '__return_false' );
}
None of this snippets help, please help!
Here is page settings screenshots!
setting page screenshot
page screenshot
Thanks in advance

I hope you are using a child theme or plugin in doing this.
Because it will just be removed when your theme updates.
In storefront version 2.2.5, it can be done with this code:
remove_action( 'storefront_homepage', 'storefront_homepage_header', 10 );
Update:
if on a child theme please do something like this:
if ( ! function_exists( 'storefront_homepage_header' ) ) {
function storefront_homepage_header() { }
}
Child themes are run first before the parent theme. By doing so, we will define this storefront_homepage_header function first. In that case, the parent theme will not create it. Applicable only on themes that uses function_exists, luckily, storefront does.
remove_action will not work because the action has not been added yet.

Try this ---
if ( is_front_page() || is_home() )
{
add_filter( 'the_title', '__return_false' );
}

Related

How can I remove short description on the shop page in Woocommerce

Shortly, I want to just remove the short description on the shop/archive page. I added two images. it will be helpful for your understanding. I tried many combination but not working on shop page.
I found a code but it was just removed on the product page.
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
function woocommerce_template_single_excerpt() {
return;
}
Option 1: To remove description entirely place the following action in your child theme functions.php
remove_action('woocommerce_after_shop_loop_item_title','electro_template_loop_product_excerpt', 80 );
Option 2: To override the function place the following function in your child theme functions.php file
function electro_template_loop_product_excerpt() {
global $post;
// In case you want to limit description for example or output different content there
if ( ! is_object( $post ) || ! $post->post_excerpt || $post->post_excerpt ) {
return;
}
}

How to change the position of the the breadcrumbs using hooks?

I am learning Woocommerce. I am on shop page and I have to display the breadcrumbs below the product header. By default it is showing like below image.
I have to display the below of the header. I want to know that what hook I have to use it.
I tried below
add_action( 'woocommerce_breadcrumb_defaults', 'woocommerce_show_page_title', 10, 2 );
but it's not working even I am also not getting my home in the breadcrumbs
You must use the following hooks to display breadcrumb under the archive title:
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
add_action( 'woocommerce_archive_description', 'woocommerce_breadcrumb', 15 );
If you need to do this on specific pages, you should use conditional tags:
// just for Shop page
if ( is_shop() && ! is_product_tag() && ! is_product_category() ) {
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
add_action( 'woocommerce_archive_description', 'woocommerce_breadcrumb', 15 );
}

Remove single product tabs and add the related content instead In Woocommerce

I have a client who wants to pull the information that defaults into tabs on single product pages in WooCommerce into a different location on the page and remove the tabs entirely.
There are three default product tabs:
product Description,
Additional Information
and Reviews.
Removing the tabs and setting up the Description to display was easy enough to set up in
/wp-content/plugins/woocommerce/includes/wc-template-hooks.php:
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
function woocommerce_template_product_description() {
woocommerce_get_template( 'single-product/tabs/description.php' );
}
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_product_description', 10 );
That works fine.
I tried to repeat the process by building out new functions that access the template files for Additional Info and Reviews like so:
function woocommerce_template_product_addinfo() {
woocommerce_get_template( 'single-product/tabs/additional-information.php' );
}
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_product_addinfo', 20 );
function woocommerce_template_product_reviews() {
woocommerce_get_template( 'single-product/review-rating.php' );
}
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_product_reviews', 30 );
But neither is displaying. What am I doing wrong here?
First woocommerce_get_template() is deprecated and replaced by wc_get_template() instead. After some searching and testing (mainly to get the reviews displayed), I have found the way:
add_action( 'woocommerce_after_single_product_summary', 'removing_product_tabs', 2 );
function removing_product_tabs(){
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_after_single_product_summary', 'get_product_tab_templates_displayed', 10 );
}
function get_product_tab_templates_displayed() {
wc_get_template( 'single-product/tabs/description.php' );
wc_get_template( 'single-product/tabs/additional-information.php' );
comments_template();
}
Code goes in function.php file of your active child theme (or theme). Tested and work (WC 3+).

woocommerce hooks and is_shop() / is_archive()

I want to do two things:
remove the breadcrumbs in category pages, but leave it in single product pages.
remove the title from the shop page.
For the breadcrumbs, I tried this code and it doesn't work:
if( is_archive() ){
add_action( 'init', 'porto_remove_wc_breadcrumbs' );
function porto_remove_wc_breadcrumbs() {
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
}
}
(without the conditional tag it does work, or if I change the conditional to if(1<2) instead).
no matter what archive page i'm displaying, with the code above the breadcrumbs is shown.
About the second problem, this code doesn't work either:
if( is_shop() ){
add_filter( 'woocommerce_show_page_title' , 'woo_hide_page_title' );
function woo_hide_page_title() {
return false;
}
}
There's still title in shop page after running this code. I guess the solution for both problems are the same.
What am I doing wrong?

Remove and Override WooCommerce Process Registration action

I'm developing a plugin to customise the woocommerce registration and trying to avoid direct editing of the core files.
I need to override or replace process_registration action in woocommerces includes/class-wc-form-handler.php file through my plugin.
add_action( 'init', array( $this, 'process_registration' ) );
I tried following links, but they didn't work. Also, the files mentioned on those pages doesn't exist on woocommerce current version. I also checked woocommerce documentation, but it seems they don't have a hook for that.
http://wordpress.org/support/topic/overriding-woocommerce_process_registration-in-child-theme-functionsphp
Woocommerce Hooks:
http://docs.woothemes.com/document/hooks/
I'd really appreciate any help!
Two options for that and considering that WC method starts like:
class WC_Form_Handler
public function __construct() {
add_action( 'init', array( $this, 'process_registration' ) );
}
public function process_registration() {
if ( ! empty( $_POST['register'] ) ) {
wp_verify_nonce( $_POST['register'], 'woocommerce-register' );
# etc
}
}
}
new WC_Form_Handler();
Add an init hook with top priority and duplicate then unset($_POST['register']). WC doesn't specify a priority, so it's running on 10, which is default.
add_action( 'init', function() { /* dup, unset, do your thing */ }, 1 ); // priority 1
Track down that evil anonymous object where Woo is hidding its hook, so that you can:
// pseudo code, go to WPSE for the real thing
remove_hook( 'init', 'woo_process_registration' );

Categories