woocommerce empty product name field - wordpress

I'm using WooCommerce 2.3.8 and WordPress 4.2.1. Is there a way to remove the product title from an individual product? I used to be able to just put a blank space and the product title would be blank, but now it doesn't let me, it just keeps putting the original product title back in when I update the product. This is only for one category of products. I would like to have a category page of products that have no titles, just the featured images in a grid.
Thank you!

1. Dirty Solution
Use CSS:
All of your list items for a product on a category have css classes named after the categories' name e.g. product_cat-mycatgegory.
You can find the product's title within an <h3> element.
Therefore the following CSS Code would prevent displaying the product's title on the category page.
.product_cat-mycatgegory h3{
display:none;
}
Note that the product title is be still readable via the browser's inspector.
2. Cleaner Solution
You could edit the content-product.php template. Check if a current category is chosen and decide whether to show the title or not. Please check woocommerce's documentation about template structure and overriding.
Pseudocode
<?php
$cat_obj = $wp_query->get_queried_object();
$category_ID = $cat_obj->term_id;
if(!($category_ID == category_ID_without_titles)) :?>
<h3><?php the_title(); ?></h3>
<?php endif;?>

Related

Wordpress Different Title Image in Category/Archive page

I would to ask how can I have a different background image for each post category in my category template. My category template is custom.
Ex.
My post category is Living Room and I want an image of living room and another post category is Bedroom and I want a bedroom image and so on for all my categories.
Thank you in advance.
You can use ACF Plugin create a or more field and put code to Archive or Category file in your Template
Read Document Tip ACF Category here
As mentioned by #dinhcode you can use advanced custom fields to add custom fields to your category taxonomy and use this field to setup images for the taxonomy term and then get the image object/url (whatever you have set as output while creating the field in acf).
Below is a small sample code:
get_header();
// get the current taxonomy term
$term = get_queried_object();
// assuming you have used image as field name and the output is set to url
$image = get_field('image', $term);

How to change WooCommerce product title on loop

how to change WooCommerce product title on loop, for example change product tile in shop, category page etc.?
I am looking for the hook that can help to solve this issue. When going to woocommerce/content-product.php it is showing
do_action('woocommerce_before_shop_loop_item_title');
echo '<div class="title-wrapper">';
do_action('woocommerce_shop_loop_item_title');
echo '</div>';
please help
I want to change the product tile on shop page, category page etc.. But in single product page, or cart, checkout page I don't want to change title. Also what about shortcodes [products ids="12,34,56,"];?
How can I change the title?
remove_action('woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title',10);
add_action('woocommerce_shop_loop_item_title','fun',10);
function fun()
{
echo 'Your Title for the product';
}
The above code will remove the Default Title and call another function which will show your own title in place. Now you have write your own logic for each product title. I tested with it, and it works for me.
Hope it works for you too.

Woocommerce shows title of the first product instead of category title

I'm using the Avano theme (no support) and the category pages are not showing the category title. Instead, it shows the title from the first product in that category.
You can see an example in their own demo: http://ninethemes.net/avano/wordpress/1/product-category/music/
As you can see the category title is: Woo Album 1. This is not the category title (Music) but the first product in the category.
Really can't figure this out. Doe anyone know how to fix this?
This is a bug in Avano theme, They have not created a header-shop.php file in the root of the theme directory. I have fixed this issue in my own way.
Activate the child theme
Make a header-shop.php file in the child theme directory
Copy and paste the content of the header.php file of the parent theme ( Avano )
Replace the h1 tage like the following
Use the following code
<h1 id="title-page">
<?php single_term_title(); ?>
</h1>
Instead of the code below
<h1 id="title-page">
<?php the_title( ); ?> // Its a wrong code - Don't use
</h1>

WordPress: display full post AND excerpts on one page

Is there a way my category archive display both full posts and excerpts?
What I want is the first two or three latest posts display as full content posts, and all the others as excerpts with just title and a read more button. These are displayed on one page. I am currently using a category archive, on the twentyfifteen theme.
I know I can set a page to either display full or just excerpts, but not a combination. Is this possible?
Thanks!
You can get these in your wordpress loop on page or post.
<?php
$content = get_content($post->ID); //full content of post
$excerpt = substr($content,0,150); //you can limit charaacter like 150
?>

WORDPRESS: Disable comments in "News" Category and Enable in "Blog" Category?

I have a News page that displays all the posts within the "News" Category. This category has sub-categories such as "Merchandise, Music, Events" ect.
I am aiming to remove comments from ALL News/Sub-category posts but only display them with the "Blog" Category posts.
Right now I have my single.php set up so posts with the "Gallery" post_format structure are displayed differently.
Here is the single.php file//
http://pastebin.com/YNf3TxT6
I am wondering what I have to fix in order to get this working...
Edit: For future viewers, here is the updated paste from the conversation below for a single.php that will only show the comments template if the post is in the "Blog" Category: pastebin.com/y9ZtCN5U
Assuming you put your Blog posts on a page separate from your news posts, you should be able to use different templates based on category.
http://codex.wordpress.org/Category_Templates
So, you could make a category-blog.php template file that doesn't include the comments code.
If all of your categories are being listed on the same page, use this instead of the in_category stuff on line 50.
<?php
foreach (get_the_category() as $category) {
if ( $category->name == 'Blog' ) {
comments_template();
}
}
?>
Not 100% sure that will work, but try it out and let me know what happens.

Resources