After trying every function I could find and 2+ days of trying every snippet possible for functions.php I have been unable to find a working solution for this.
I am trying to remove the WooCommerce description and review tab, and just display the description in place of the tabs, and have the contents of the reviews tab beneath it... with no tabs to click. - I an unset the tabs and remove, but cannot add their contents back in.
I have tried "Remove single product tabs and add the related content instead In Woocommerce" answer code.
I do not mind even overriding php in the theme, but nothing seems to work... the goal is just to have the description show, and the reviews beneath with no tabs. Any help is appreciated.
To remove the tabs but display the content you can use the following.
// Remove
function remove_product_tabs( $tabs ) {
unset( $tabs['description'] );
unset( $tabs['reviews'] );
unset( $tabs['additional_information'] );
return $tabs;
}
add_filter( 'woocommerce_product_tabs', 'remove_product_tabs', 98, 1 );
// Tabs callback function after single content.
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_product_description_tab' );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_product_additional_information_tab' );
add_action( 'woocommerce_after_single_product_summary', 'comments_template' );
To avoid collapsing, edit the following template
https://github.com/woocommerce/woocommerce/blob/master/templates/single-product/tabs/description.php
This template can be overridden by copying it to yourtheme/woocommerce/single-product/tabs/description.php.
Replace
<?php if ( $heading ) : ?>
<h2><?php echo esc_html( $heading ); ?></h2>
<?php endif; ?>
<?php the_content(); ?>
With
<div style="clear:both;">
<?php if ( $heading ) : ?>
<h2><?php echo esc_html( $heading ); ?></h2>
<?php endif; ?>
<?php the_content(); ?>
</div>
Further customization is a matter of html and/or css modifications, depending on your theme
Related
Ok, so I have added my own title in the header.php
<title>
<?php
if (!(is_front_page())) {
wp_title('', true,''); ?> (<?php the_time( 'Y/m/d' ); ?>)-
<?php }
echo get_bloginfo( 'name' ); ?>
</title>
It works great.
The problem is that when I click on View Source, I see two title codes.
First one is my title that I manually added to header.php
And the second one is the default Wordpress title.
My question is, where do I need to modify (probably in the functions.php?) to remove the default Wordpress title?
Might be able to use this in your functions.php based on: wp-includes/default-filters.php
remove_action( 'wp_head', '_wp_render_title_tag' );
UPDATE
Based on your theme I recommend you remove your custom title from the header, remove the above remove_action i previously suggested and use the below solution in your functions.php. this will hook into the existing theme title and modify its value using your custom title code:
add_filter('wp_title', function($default_title){
$title = '';
if (!is_front_page()) {
$title .= wp_title('', false,'') .' '. get_the_time( 'Y/m/d' ) . '- ';
}
$title .= get_bloginfo( 'name' );
return $title;
});
Here's the working sulution. Just paste the below code to your functions.php:
remove_action( 'wp_head', '_wp_render_title_tag', 1 );
I'm having trouble getting my product page to display correctly.
I'm hoping to try and get a result like this on my product page. (Description & attributes horizontal in same tab)
As you can see in the picture the description is on the left and the attributes show on the right.
On my site, I have currently removed the attributes tab and have it nested underneath the description, using this code in my functions.php:
add_filter( 'woocommerce_product_tabs', 'exetera_custom_product_tabs', 98 );
function exetera_custom_product_tabs( $tabs ) {
// Custom description callback.
$tabs['description']['callback'] = function() {
global $post, $product;
// Display the content of the Description tab.
the_content();
// Display the heading and content of the Additional Information tab.
echo '<h2>Specifications</h2>';
do_action( 'woocommerce_product_additional_information', $product );
};
// Remove the additional information tab.
unset( $tabs['additional_information'] );
return $tabs;
}
Just can't figure out how to get it to sit horizontally next to each other.
Any help would be greatly appreciated, Thanks in advance!
You have to wrap the content of the tabs in divs and then align/style them with CSS.
However, this is theme dependent and so my answer is reduced to the absolute basics.
add_filter( 'woocommerce_product_tabs', 'exetera_custom_product_tabs', 98, 1 );
function exetera_custom_product_tabs( $tabs ) {
// Custom description callback.
$tabs['description']['callback'] = function() {
global $post, $product;
echo '<div class="description left" style="float:left;width:49%;">';
// Display the content of the Description tab.
the_content();
echo '</div>';
// Display the heading and content of the Additional Information tab.
echo '<div class="specifications right" style="float:right;width:49%;">';
echo '<h2>Specifications</h2>';
do_action( 'woocommerce_product_additional_information', $product );
echo '</div>';
};
// Remove the additional information tab.
unset( $tabs['additional_information'] );
return $tabs;
}
I am working with a WordPress theme which includes woocommerce, and I'm aiming to modify the appearance of the standard shop-categories-pages. Unfortunately I’m a WP-newbie and not very familiar with coding. Therefore I would be very grateful for your help.
I'm failing for days to create a php-snippet for my child-theme functions.php, that hides the banner and the title ONLY on the Shop-categories- and subcategories-pages, WITHOUT hiding them on the Shop-Starting-page.
Although I found a working code to effectively hide the banner and title on EACH Woocommerce page,
add_filter( 'woocommerce_show_page_title', '__return_false' );
and had some success with this conditional-logic-code-example from businessbloomer.com
add_action( 'woocommerce_before_main_content', 'bbloomer_loop_cat' );
function bbloomer_loop_cat() {
if ( is_product_category( 'segel' ) ) {
echo 'This will show on the Segel Cat page';
} else {
echo 'This will show on all other Woo pages';
}
}
I’m constantly failing to combine these 2 codes. I guess I have tried dozens of combinations but nothing seems to work. Therefore I desperately need some support and would appreciate any help.
With kind regards
Reca
P.S: Some additional information:
Here is some code of the archive-product,php, if this is relevant
<div class="woocommerce-products-header page-banner">
<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
<div class="title-inside shop-page" style="background-image: url(<?php echo esc_url( $banner_url ); ?>);">
<div class="banner-wrapper <?php if ( empty( $banner_url ) ) echo 'no-banner-img' ?>">
<h1 class="woocommerce-products-header__title page-title"><?php woocommerce_page_title(); ?></h1>
The CSS-command
.title-inside.shop-page {
display: none; }
works also perfect in hiding banner and title on ALL Woocommerce pages. Unfortunately I‘m failing here in total to add some if-conditions.
Please see my separate question, depending CSS.
function woocommerce_template_product_description() {
wc_get_template( 'single-product/tabs/description.php' );
}
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_product_description', 20 );
This code prints a product description, but I'd like to add the text "Description:" before the description itself without having it on a separate line. How do I go about that? I am a total beginner when it comes to coding. Thanks!
In WordPress/WooCommerce Product are nothing but a Post. So the the product
description is treated as the_content of a post.
If you just want to add custom text/content before the Product Description then just use the_content filter.
Here is the code.
function theme_slug_filter_the_content($content)
{
//Only for single product page.
if (is_product())
{
$prepend = 'Description';
$content = $prepend . $content;
}
return $content;
}
add_filter('the_content', 'theme_slug_filter_the_content', 9); // <-- Choose some priority <
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
The code is tested and fully functional.
Reference
the_content
is_product
You have to locate the template file and edit the template file, so that it renders the desired output.
This loads a template file only
You need to edit that specific file "single-product/tabs/description.php"
and add a echo there.
Case-1 : Add "Description" in tab
Path : templates/single-product/tabs/description.php
<?php echo "<b>Description</b>"; the_content(); ?>
Case-2 : Add "Description" in Short description area
Path : templates/single-product/short-description.php
<?php echo "<b>Description</b>"; ?>
<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>
Is there any possible way to change the loop structure of the Genesis Framework so that the loop header appears within the same div as the entry content?
I have tried messing around with the loop.php file in the genesis template and I have also tried looking up different hooks, but I can't seem to find anything that helps.
Is there anyone that has accomplished this or would have an idea?
To customize the loop in Genesis, before you need to remove Genesis Loop:
remove_action( 'genesis_loop', 'genesis_do_loop' );
then you can add your custom loop
add_action( 'genesis_loop', 'my_custom_loop' );
Here is a basic example for 'standard-looking' loop working in Genesis:
function my_custom_loop() {
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// Your Code Here
<?php endwhile; ?>
<?php endif; ?>
<?php
}
genesis();
?>
Please note that your function must end with 'genesis();' to work!
So the whole page code can be:
<?php
/*
* Your Custom Page
*/
?>
<?php
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'my_custom_loop');
function my_custom_loop() {
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// Your Code
<?php endwhile; ?>
<?php endif; ?>
<?php
}
genesis();
?>
Hope it helps ;)
Here is simple approach.
You first remove the entry header stuff from the header.
e.g.
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_post_info', 12 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
Once the header markup as well as entry title and entry info is removed from top.
You can add them back into your page in your desired position i.e. genesis_entry_content hook.
e.g.
add_action( 'genesis_entry_content', 'genesis_do_post_title' );
Hope this helps. Let me know if you face any issue.
Sorry forgot to add that you will need to add this custom code in your child theme's functions.php file if you want it to impact to whole site. And if you want this to happen on certain template, then in that template file in the child theme of Genesis.
I list all the most common Genesis hooks and filters used by me while developing a website without boring you with more contents.
https://icodefy.com/common-genesis-hooks-filters/