Tks.
]]>I have a few categores, let’s call them A, B, C, D, E… and so on.
From the backend, I gave category images to each categories.
Now, let’s say I post a product in the category A without selecting any images.
The product just shows the woocommerce default image (the one with the grey background).
Is there a way to use the category images as the default product image when there is no image selected?
I have tried a few codes, this is the last one I have:
add_action( 'init', 'custom_fix_thumbnail');
function custom_fix_thumbnail(){
add_filter('wc_placeholder_img_src', 'custom_woocommerce_placeholder_img_src');
function custom_woocommerce_placeholder_img_src( $src ) {
if (is_shop() || is_singular('product') || is_archive() || is_checkout() || is_cart()) {
global $post;
$array = get_the_terms($post->ID, 'product_cat');
reset($array);
$first_key = key($array);
$thumbnail_id = get_woocommerce_term_meta($first_key, 'thumbnail_id', true);
// get the image URL for parent category
$image = wp_get_attachment_url($thumbnail_id);
// print the IMG HTML for parent category
if ($image)
$src = $image;
}
return $src;
}
}
]]>Is there a way to say “if a post doesn’t have a category, then just use /%postname%/”?
Thanks for any help!
-Dan
If you take a look at https://www.gaming4u.be/category/games/ you’ll see a category page where all my games are listed.
Now I would like to have a search bar (different of the main search bar at the top of the website) to search games in that category page.
How can I do this? A plugin would be nice
Many thanks in advance,
Thibault
]]>I want to create a page with some content and images about Acura cars then feed in the post snippets contained in the URL above?
How can I do this? Is there a PLugin or do I need some custom coding?
Thanks
]]><?php $cat_id = get_cat_ID('cat-slug'); ?>
<a href="<?php echo get_category_link($cat_id) ?>">link</a>
for some reason get_category_link is just returning nothing. I noticed that I can access the category weirdly enough via a simple /cat-slug off the main structure of the website. Is this new to 3.2.1? I thought this was only possible with pages previously and categories always had the /category/cat-slug URL. If I go into the admin and “view” the category, sure enough the URL is /category/cat-slug but in my code if I simply put:
<a href="<?php bloginfo('home')?>/cat-slug">link</a>
it works. Not that I am complaining really, this makes things easier, but I’m just wondering if something weird is going on?
Thanks in advance.
]]>I have set up “categories” for posts to fall under, let’s say A, B, and C. I am trying to set up things in such a way that, in the menu, there is a “Page A”, “Page B”, and “Page C” under which all postings categorized as “A” show up in page A and so on. For an example, see https://www.designingsound.org — I’m not entirely sure how they do it, but they have “articles” “interviews” and “specials” etc. Any ideas?
]]>Somebody who knows?
thanks in advance
gereeting
bwerner