Linked Questions

0
votes
1answer
332 views

Performance of storing multiple meta fields vs one JSON encoded field [duplicate]

I have several custom post types. For some i need to query them based on a single meta field, but for others i have a dozen individual meta fields. If i create an array and convert it into JSON, will ...
1
vote
0answers
263 views

get_metadata() vs get_post_meta() vs custom query [duplicate]

I have 27 items of post_meta data that I need to get out in a class that I use through-out my website. Currently I'm using: $this->postMetaData = get_metadata("post", $postID); This returns an ...
20
votes
4answers
26k views

Can wp_query return posts meta in a single request?

I would like to create a wp_query that would return posts meta inside the posts array. $args = array ( 'post_type' => 'page', 'meta_key' => 'someMetaKeyName', ); // The Query $query = ...
9
votes
5answers
14k views

How do I query for posts by partial meta key?

I have a function that stores the "like" status for a post as post meta. I want to associate that "like" with the user that liked it, so I setup a custom field called "like_status_{user_id}" (where {...
2
votes
3answers
1k views

Get random custom-post-type post to display within content

I have a function, within functions.php (all code below), that adds an advertisement after x amount of paragraphs to any given single.php post. I have a custom-post-type called advertising that has a ...
2
votes
1answer
2k views

get_post_custom()

There's very little said about get_post_custom() in codex. I also couldn't find any good explanations or usage from G search. My current understanding is that it gets all the post meta related to the ...
4
votes
3answers
341 views

Is there a blog info object?

The functions get_bloginfo() and bloginfo() both return information about the blog but accessing it each time seems unnecessary. Is there a function that will return the bloginfo as an object with ...
3
votes
1answer
996 views

Custom Fields and performance

My question : how many custom fields or even taxonomies WordPress can handle without affecting performance? The reason I ask, is because I started building a custom theme and I might need to have ...
1
vote
1answer
1k views

Get attachment by meta_key value

I need to get the attachment (will be only one per post) associated to a post with meta_key wpcf-legislacion-gratis (not matter the value the column has) by using a custom query using get_posts() ...
0
votes
2answers
685 views

How to hide a div based on contents of custom field

I've found several other threads asking this same question, but for some reason I can't seem to make a solution work for me. For clarification, I want to have a custom field that is applied to a post ...
-1
votes
1answer
719 views

How to show all posts of specific custom post type with their custom fields values?

I am trying to get the list of all posts with post_type "staff" along with custom fields assigned to this post_type. Custom fields were create with help of ACF. I've tried both: $query = new ...
0
votes
1answer
648 views

Storing post_meta fields in array

I need to have 8 separate post meta fields on each post in wp-admin (shown in a custom meta field box). I'd like the data from these 8 fields to be stored in an array as one post_meta field for easy ...
0
votes
1answer
287 views

Is it possible to set a variable for get_post_meta?

I have a lot of places within my templates where I get custom post meta set up with CMB2 and I was wondering if it's possible to set get_post_meta( get_the_ID() ) to a variable like $service_meta = ...
0
votes
2answers
260 views

Optimising amount of calls to custom fields

I have this code fragment in my codebase: foreach($this->adverisers as $adveriser) { $this->data[$adveriser->name]['image'] = bfi_thumb(get_post_meta($adveriser->ID, ...
0
votes
1answer
195 views

Get most recent post for every term in a given taxonomy type

I'm looking for an efficient way to retrieve the most recent post from every term for a given taxonomy type. I found this question, which provides the same solution I came to on my own: $terms = ...

15 30 50 per page