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?
- How do I delete all UNUSED images from my uploads directory?
- Programmatically get images by URL and save in uploads folder
- Download an image from a webpage to the default uploads folder
- How to change image type for specific size?
- is it possible to replace the use of gd_lib with imagick or ImageMagick?
- How to give image source in wordpress page editor?
- Change WordPress image URLs via filter
- get_the_post_thumbnail_url with an unregistered size
- Any easy way to automatically set the first inline image in a post as the thumbnail?
- Upload multiple images in a custom metabox
- Insert an image into a post by API
- Programatically creating image attachments from local URLs and setting featured image
- set_post_thumbnail_size not cropping featured images, but reducing proportionally
- How to grab first image attached to post and display in RSS feed?
- Double thumbnails?
- Caption in Page adding unwanted 10px to width
- No srcset for hard-cropped thumbnails
- Is it possible to prevent users from uploading small images?
- Can’t Display Featured Image in RSS Feed
- Displaying a featured image (only img url) as the img src?
- Did I do it right? Deleting images after deleting product. Woocommerce
- When displaying the featured image, is has_post_thumbnail() necessary?
- Get original image from thumbnail URL
- Images not working using Featured post
- Add instructions to featured image
- WordPress reduces the full size image and uses it as the original
- How do I get more image editing options in the admin?
- Special purpose photos with each post
- Set Post Image Using Shortcode
- Print specific image size in galley loop
- Can’t seem to attach uploaded image to post and set it as thumbnail
- Big Image on Featured Post, Normal on Single Post
- offload media to external services [closed]
- Store Snapshot created via wordpress to use with lightbox
- How to stop thumbnail generation from some images and different size thumbnail generate
- How to stop wordpress always displaying full-res images
- How can I add a “data-pin-nopin” the featured image html?
- wordpress (woocommerce) add image to media library programmatically python
- Resize into square the single product image in woocommerce without cropping [closed]
- WordPress PNG compression issue
- Custom Loop, Match Category with Page: How to display post featured image?
- Redirect to another page using contact form 7? [closed]
- Generate images to be associated for tag and category?
- How do I get my main image to stretch the full length of the screen?
- Filter for post_thumbnail: link to small src and add data-attribute [duplicate]
- Bulk-add featured images in posts with no featured image
- Why doesn’t WordPress use the smaller sized image?
- How to set featured image from external url programmatically
- Hide Featured Image box – isn’t working?
- Remove Additional image sizes created by theme
- 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
- How to add thumbnails to posts and pages automatically in a uniformed fixed elegant way?
- resize and crop thumbnail photos
- Images not uploading on product page of woocommercr
- How to only show div of caption if caption exists on featured image
- Is there a way to add a featured image to an image/file attachment page?
- 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
- attachment_fields_to_save first parameter is null
- 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?
- How to set a post featured image from an already made custom field
- stop wordpress from resizing feature gif images
- How to delete images from database with product
- second featured post not displaying on page [closed]
- WooCommerce Variation Swatches and Photos – get attribute thumbnail
- Bypass wp_safe_remote_get()?
- set_post_thumbnail_size only working for width
- 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
- Image thumbnail on single product issue | WooCommerce
- Url link to feature image in the portfolio [closed]
- How do I get resized thumbnails?
- Why is WordPress loading a different sized post thumbnail?
- Create post thumbnails from images stored outside of uploads directory
- Title image is missing ( but is not the WP 3.5 issue )
- Images will not attach to posts after site migration
- 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)
- WordPress pointing animated GIF images with wrong file name upon upload (GIFs animation not working)
- Edit multiple posts featured image
- Is there a way to upscale a media library original image to the nearest whole pixel in WordPress?