How can I remove the Featured Image in Woocommerce? - woocommerce

I've searched the forums, but I think the code is too old now. How can I remove the Featured Image in Woocommerce? Thank you!

Try this plugin and then use a function to show the second image of the gallery. Otherwise it will show the empty space that the featured image left.
Second option, try this snippet:
function my_post_image_html( $html, $post_id, $post_image_id ) {
if(is_single()) {
return '';
} else
return $html;
}
add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
More useful info and options here.

Related

Add a shortcode above the WooCommerce product short description

I am trying to add a shortcode to all my woocommerce single product pages. I want the shortcode to appear above the short description.
I have found this code and added it to functions.php, but I can see that it adds the shortcode below the short description (and above the add to cart button).
add_filter('woocommerce_short_description','ts_add_text_short_descr');
function ts_add_text_short_descr($description){
$text = do_shortcode('[my-shortcode]');
return $description.$text;
}
I would be very gratefull for some help :)
function customShortcodeBeforeShortDescription( $post_excerpt )
{
echo do_shortcode('[wpqr-code]');
}
add_filter('woocommerce_short_description','customShortcodeBeforeShortDescription', 10, 1);
You can use the woocommerce_single_product_summary action hook. try the below code. The code will go in your active theme functions.php file.
function add_shortcode_before_short_description(){
echo do_shortcode( '[wpqr-code]' );
}
add_action( 'woocommerce_single_product_summary', 'add_shortcode_before_short_description', 15, 1 );
Tested and works

How to show some html after featured image?

I have a related post code and I wants place it just after featured image on single post page. I have tried,
add_action( 'loop_start', 'wcr_related_posts', 10, 0 ) ;
but it doesn't work as I want to show content. It does show content at about proper place but the sidebar is not moving, just content is being shown a bit below and I also want the sidebar to come below due to code that wcr_related_posts generates.
I have not been able to find a hook that actually works that way I want it to.
You can do this using the 'the_content' filter:
add_filter( 'the_content', 'insert_featured_image', 20 );
function insert_featured_image( $content ) {
$content = preg_replace( "/<\/p>/", "</p>" . get_the_post_thumbnail($post->ID, 'post-single'), $content, 1 );
return $content;
}
Get the more details and examples as follow link : https://wordpress.stackexchange.com/questions/61272/how-do-i-add-the-featured-image-to-the-content-after-the-first-paragraph

when I set content limit 0 the more link disappear in genesis why?

I want to display: content limit should be 0 and read more link also appear in Genesis. This is my code:
add_filter ( 'get_the_content_more_link', 'custom_read_more_link' );
function custom_read_more_link() {
return '... <a class="more-link" href="' . get_permalink () . '">Read More</a>';
}
If any one know the answer, please help. Thanks in advance.
Go to Dashboard > Genesis > Content Archive and set Display option to Entry excerpts
Copy the following code to functions.php
//* Modify the length of post excerpts
add_filter( 'excerpt_length', 'sp_excerpt_length' );
function sp_excerpt_length( $length ) {
return 0; // pull first 0 words
}

Disable WooCommerce SKU on Product Page

I have a WooCommerce store and I don't want to display the SKU on any single product page. Looking at their code, I found this filter:
/**
* Returns whether or not SKUS are enabled.
* #return bool
*/
function wc_product_sku_enabled() {
return apply_filters( 'wc_product_sku_enabled', true );
}
and I attempted to override it with this line of code I placed in a custom plugin:
apply_filters( 'wc_product_sku_enabled', false );
I also tried placing the apply_filter inside an action function for woocommerce_product_meta_start which fires right before but it still renders the SKU on the product page. Any ideas?
I think you shoul try with this:
add_filter( 'wc_product_sku_enabled', '__return_false' );
That will remove sku from all woo, back and front end. You can always hide it just by CSS if need it on admin.
The easiest way is with CSS:
.sku_wrapper {
display:none;
}
A more robust approach is to recreate the woocommerce template woocommerce/templates/single-product/meta.php in your own theme and simply comment out the line:
<span class="sku_wrapper"><?php _e( 'SKU:', 'woocommerce' ); ?> <span class="sku" itemprop="sku"><?php echo ( $sku = $product->get_sku() ) ? $sku : __( 'N/A', 'woocommerce' ); ?></span>.</span>
To recreate a woocommerce template in your own theme, see:
http://docs.woothemes.com/document/template-structure/
Hiding the SKU/UGS by using cSS is not an efficient solution because it will be still part of the HTML code.
In order to hide it from the product single page and keep it in the admin page, you have to add this code in the child (or parent if you don’t have the child) functions.php :
// Remove the Product SKU from Product Single Page
add_filter( 'wc_product_sku_enabled', 'woocustomizer_remove_product_sku' );
function woocustomizer_remove_product_sku( $sku ) {
// Remove only if NOT admin and is product single page
if ( ! is_admin() && is_product() ) {
return false;
}
return $sku;
}
Make sure also in the product php page (it can have a different name depending on the theme you use) to have this condition to show the SKU in the product single page:
if (wc_product_sku_enabled() && $product->get_sku()) { // HTML code that shows the SKU in the product single page}
Make Sure to remove it from the frontend only by using this code on function.php usually you can edit the function file on theme editor
add_filter( 'wc_product_sku_enabled', 'my_remove_sku', 10 );
function my_remove_sku( $return, $product ) {
if ( !is_admin() && is_product() ) {
return false;
} else {
return true;
}
}
If you don’t need to use SKUs at all in your shop, you can disable them completely by using this plugin. simply install this plugin. https://wordpress.org/plugins/woocommerce-remove-sku/

How to add a button or box below Post Title?

I'm writing a Wordpress plug-in that will add a button (or any HTML element) below the post title (or above if below is not possible). How can I do that?
You want to use the filter responsable for printing titles. I'm not sure exactly which one it is, but here's the function (it's likely single_post_title as demonstrated):
add_filter( 'single_post_title', 'the_post_title', 10, 2 );
function my_more_link( $post_title ) {
$button_code = "your_button_HTML_here";
return str_replace( $post_title, $post_title . $button_code );
}

Resources