Thanks to you I tried this on my functions.php
It worked, but also had to get the ID of the page, in my case 4.
add_action( 'woocommerce_before_main_content', 'woocommerce_category_image', 2 );
function woocommerce_category_image() {
if ( is_product_category() ){
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
if ( $image ) {
echo '<div class="category-image"><img src="' . $image . '" alt="' . $cat->name . '" /></div>';
}
}
if ( is_shop() ){
$target_post_id = '4';
$image = wp_get_attachment_url(get_post_thumbnail_id($target_post_id));
echo '<div class="category-image"><img src="' . $image. '" alt="' . $target_post_id->name . '" /></div>';
}
}
Related Posts:
- Product Images Low Quality After Updating From WP 3.5 to 4 [closed]
- Why does wp_get_attachment_image_src return the wrong size, when the correct size exists?
- Filter to remove image dimension attributes?
- How do I delete all UNUSED images from my uploads directory?
- Stop wordpress from hardcoding img width and height attributes
- Programmatically get images by URL and save in uploads folder
- How to automatically add rounded corners to thumbnails?
- WordPress adding scaled images that don’t exist (1536×1536 and 2048×2048)
- Download an image from a webpage to the default uploads folder
- All Images not calling alt text
- How do I link a featured photo to it’s post?
- Hide Featured Image box – isn’t working?
- Can we use featured image as third party website image URL
- Is it possible to enable the ‘Link To’ field under ‘Attachment Display Settings’ for a Featured Image?
- Show (print) featured image all dimensions (height, width)
- How to make footer area transparent? Using Avada and WordPress [closed]
- Remove Additional image sizes created by theme
- Use default image as var
- add_image_size not working
- Serve different images per screen size and cache possible?
- Set two default featured images
- adding image to post thumbnail from another server
- Hide image gallery in Woocommerce if NO image [closed]
- Set Featured Image not opening – Stuck at loading
- Placing a featured image into header
- Convert featured images into “product images”
- How to add thumbnails to posts and pages automatically in a uniformed fixed elegant way?
- Resize uploaded images [duplicate]
- resize and crop thumbnail photos
- How do I display the featured image from an image gallery using a reference in code? (example within)
- How to use the thumbnail size with catch_that_image
- Using different size thumbnails on different parts of my site… with functions.php?
- Thumbnail and image management
- attach several images to post + gallery
- How do I make the product image smaller on a WooCommerce product page?
- Images not uploading on product page of woocommercr
- my featured image of wordpress are not showing in the front end though image are uploaded in media library
- How to only show div of caption if caption exists on featured image
- How to change Gallery image url in product page ? In function.php?
- How to make product image inherit from category image
- How is called this thumbnail slider feature
- Is there a way to add a featured image to an image/file attachment page?
- Custom image size not displaying with wp_get_attachment_image()
- How to use default image as featured image by implement some code in function.php
- WordPress Multisite: Images moved to /sites/1?
- How to echo images Urls from a wordpress post, that are relally in the post
- WordPress Responsive Image ( srcset ) not work properly
- How to Display Image Caption but Not Alt Text
- How to delete original image file after upload and resize
- attachment_fields_to_save first parameter is null
- An error has occurred during the upload process in wordpress version 5.3.2
- Force WordPress to always generate a thumbnail for original image
- Show featured image in all posts
- Get post thumbnail in specific size
- When upload a PNG a noise appears in the thumbnails
- Image alt attribute
- I cannot upload images to post or the media library in wordpress
- Images missing from Blog post page
- Why image Thumbnail url is not displaying with custom size?
- Exclude first image from a Woocommerce image gallery
- How to set a post featured image from an already made custom field
- featured image in custom poste type (backend)
- Custom Background for each page and post
- stop wordpress from resizing feature gif images
- How to delete images from database with product
- second featured post not displaying on page [closed]
- Using custom field to change alt text for a featured image
- WooCommerce Variation Swatches and Photos – get attribute thumbnail
- How can the alt be added to this wooCommerce category image?
- Bypass wp_safe_remote_get()?
- set_post_thumbnail_size only working for width
- Use a different catalog image than the featured image
- Delete post if featured image is smaller than Y pixels by Y pixels
- Newly uploaded images are not updating in featured image
- Troubles with code for upload a image
- How to display image thumbnails on the search results page?
- Image thumbnail on single product issue | WooCommerce
- Declare global variable that can be used on other function
- Gallery Images could not be shown
- Get custom size of thumbnails
- Url link to feature image in the portfolio [closed]
- Thumb doubles the image file size
- How do I get resized thumbnails?
- Black and White Thumbnail in WordPress Gallery
- Editing Featured Image Display When Creating Post
- Making a thumbnail if there exist a link with. jpg or .png extension in WordPress
- Why is WordPress loading a different sized post thumbnail?
- Create post thumbnails from images stored outside of uploads directory
- how to display all images from their siblings/ from same parent?
- Title image is missing ( but is not the WP 3.5 issue )
- Images will not attach to posts after site migration
- Getting top Image From the Gallery and printing out a thumbnail with Exact Dimensions
- Using the on-board image editor for featured images: edits are not being used
- Featured Image not changing
- Tried everything but Facebook share button won’t load the post thumbnail
- has_post_thumbnail() Returns False on Scheduled Posts
- WP is showing wrong image dimensions
- Why some images are not allowed to be edited only for thumbnails?
- I tried to move the featured image below the paragraphs but now it is displaying twice
- How to import external media items into wordpress media library (without using storage)