Linked Questions

2
votes
1answer
10k views

Can't get post ID in functions.php?

I need the current post id in a function , which I have written in functions.php. But I can't get the id. I have tried several method. Like get_the_ID(); //returns false global $post; $id = $...
6
votes
2answers
2k views

New image size version only for the Featured Image file

I'm worried about too many files created when adding a new image size. All uploaded files will generate the new size, I need a specific image size only for the file set as Fetured image, is there ...
3
votes
2answers
2k views

Is there a hook / action that is triggered when adding or removing a post thumbnail?

I'm trying to update a custom field after a post thumbnail (Featured Image) is either added or removed from a post. The aim of this is to keep track of whether a featured image has been added or ...
0
votes
1answer
5k views

is there an update_post_meta action

Are there any actions I can hook into for update_post_meta()? I don't see anything obvious in the source. Woocommerce lets you change the featured status of items via ajax from the edit screen. I ...
1
vote
2answers
2k views

Filter For Featured Image

Is there a filter for when a Featured Image is set/unset or changed. I need to delete transient data when the above occurs.
1
vote
2answers
705 views

Determine when a custom field was last updated?

Would anyone know of a way to determine when a custom field for a post was last updated? I'm trying to write something that says "If CUSTOMFIELD was updated in the last 24 hours don't do anything, ...
1
vote
0answers
1k views

Compare meta_query with a Regular Expression and do a less-than operation on it

I have the problem that my client is using a theme which stores options of items in a serialized way in the post_meta table. I already found out that this is not the best way to save values ...
-1
votes
2answers
901 views

How can I add a custom meta value on file upload?

I am looking for an option where a custom meta value will be saved when user uploads an attachment. Lets say I need a meta key _example_meta_key and want to save meta value of this as ex087659bh (It ...
0
votes
1answer
497 views

A faster way to query custom post types with multiple conditions?

I am using a lot of custom post types (CPTs) with custom meta and so far I have been using queries like the below, to get for example all events in CountryX that happened in 2014: <?php global $...
2
votes
1answer
266 views

Automatically Add Specified Value to Attachment Metadata upon Upload

I am trying to create a function that automatically adds a value to the attachment metadata (if it matters, on Audio uploads). For example, I want to add a value of 'artist' and output it as my own ...
0
votes
1answer
97 views

Can I use pre_get_posts to add up values from two different meta_keys?

I'm storing post meta values _likes and _dislikes in postmeta. In some cases, I want to be able to query for posts by their netto score (likes minus dislikes) and order them by it. I'm familiar with ...