Wordpress: Get link to the post an images was used in - wordpress

I'm want to use the Recent Photos Plugin in my sidebar to show the last uploaded photos but instead of linking them to the bigger versions of the images I want to link to the post they were used in.
Can somebody tell me how I get the link of the last post an image was used in?
Thanks, udo

If you do a sidebar based on the posts and display the image you can display the image from a post then have it link to the permalink based on the post. If you do it based on the images like you are doing, there is no identifier that tells wordpress whether or not the image is part of any particular post. So in turn if you wanted, you can set a condition to pull posts and put it in a array and have it cross reference and descend the order by the date of upload per image.

Related

How to display images of a post as a media gallery in wordpress

Situation
I used user-frontend API to make user capable of uploading image. But this post page posts the image and the image is visible in media library(which contain other previously submitted posts as well).
Problem
I want to display the images associated with a particular post to be displayed as a media gallery.
Methods I tried
user-frontend API had option of selecting post type as user gallery but even after opting for it its not working properly.
I think I can use user-post gallery API that allows me to display the images as a gallery, but I dont know how to integrate both the APIs.
I have some other requirements for which user-frontend API is best choice so cant remove this.
I need some guidance regarding how it can be done maybe through above methods or some meta key or php code.
Kindly ignore the silliness. Its my first wordpress project:)
Direct me if its not possible or if it is possible only without user-frontend API.

Display different image for different url

I have a WordPress Woocommerce e-shop.
In every product category, I want this to have a different top image.
The Woocommerce category pages are automatically created so I can't edit them individually.
I have managed to find a way to have my own image on top but I want this image to be different for different categories.
So I thought that if I could handle the images displayed inside this by referring to their URL this would solve the problem.
So let's say for URL
example.com/category/category1
display image-1 and so on.
Something like a CSS selector
div[this-url-1] {background-image:url(.image-1..);}
div[this-ur2] {background-image:url(.image-2..);}
You can use this plug in to do what you want.
https://wordpress.org/plugins/woocommerce-category-banner/
This will allow you to use custom images and positions of images for each category.

Wordpress / woocommerce - Output “parent“ product of an image in the media library

I am building a visual search, where a user can upload a photo. This photo gets checked against all images in my media library. If I get a hit, than the corresponding product should be outputted.
Is there a way to identify the product to which an image is assigned. Either as product image our gallery image.
(Update: I forgot to mention it's for woocommerce. So I need the product it's attached to)
I dont think there is a way to get the post id of an image without looping through every product checking if the image id is attached to the post.

WORDPRESS: How to identify media by title instead of ID in a gallery

I'm working on a mass upload of images and gallery posts, so I would like to prepare my posts offline.
The gallery code is [gallery include="94,104"] where the ID numbers are assigned by WP at uploading time.
It would be a big help to modify the gallery script so media could be referred by post_title,post_name or guid, so the post content can be prepared without knowing the ID. Ideally, I would like to do: [gallery include=" IMG_4736.jpg"].
Unfortunately I haven't found a way to identify a media element by its file name.
Any help would be much appreciated.
There are two aspects to this, first you can find media elements by the title with an instance of the WP_Query class, or you can use get_posts(). Set the post type to attachment and of you go.
Secondly to use the titles as the identifiers in the shortcode you are going to need to
add_filter( 'post_gallery', 'my_function' );
This will allow you to alter the way files are selected and presented for the shortcode. See the source code for what is output ordinarily.
I must say, it seems a strange approach - the ID is the best way to uniquely identify an item (what if you get two images with the same title?). You know you can add a gallery using the 'Add Media' button and that will insert the ID's for you? - just checking :)

Wordpress: Create blog posts from Tweets and YouTube videos automatically?

I am building a Wordpress site, but I'm struggling to find a good plugin to achieve a few things...
Basically I want to make the website a central hub of a lot of my social networks, without me having to continaully update things in several places. So I'm wanting to do the following:
Every time I post a new Tweet, I want it to create a new Blog post on my website in the Tweet category. The post should have a default featured image and a I should also be able to set where the Tweet is displayed (i.e. in the title and post content) and if anything else is displayed after the tweet (like a follow button) for example.
Secondly, every time I upload a new video to YouTube, I want it to create a new blog post on my site in the Video category (and preferably in the Video Post Type) automatically. Again, I should have control over what is pulled into the post other than the video... for example description, tags etc. I would also like it to set the Featured Image of the post to one of the three still images that YouTube creates for a video.
Is the above achievable, and how would I go about figuring it out?
Many thanks in advance,
HT
For the first part of your question, I'm doing something similar. I'm using Twitter Tools plugin; along with Social.
HTH

Resources