Questions tagged [post-meta]

Post meta is a data set containing additional core as well as custom post information.

Filter by
Sorted by
Tagged with
0 votes
1 answer
100 views

Add post's category as a meta tag to the post

For tracking purposes, I need to add a meta tag to each blog post with the post category it's in. The meta tag would need to look like this: <meta name="category" content="politics&...
David Morin's user avatar
3 votes
0 answers
82 views

How do I manage custom meta in post revisions in the Block Editor era?

Note to admins: I have been trawling every possible resource for this but cannot find a good answer for modern WordPress, so please don't mark this as a duplicate of ("insert some answer from ...
codewithfeeling's user avatar
0 votes
1 answer
31 views

Display current ranking of post as a number in post title

I have a page where people can rank stuff. My posts are ordered by the current ranking which is stored as a meta key in post meta. Now i want to add the current ranking spot within the title of the ...
Jawequo's user avatar
0 votes
0 answers
45 views

Search post overlapping dates - meta_query with meta_key

I'm having a search form for rentals that search locations available according to a date range. For now, I store all reserved dates for each posts as post_meta. For exemple ; post_id: 231 post_meta : ...
Daniel Ringuet's user avatar
0 votes
1 answer
124 views

Meta field bulk editing no longer working in WP 6.0 [closed]

Until recently, I was using the following PHP and jQuery code for adding bulk editing support for a meta field (price) in a custom post type (Book): PHP: function show_bulk_edit_book_metabox( $...
leemon's user avatar
  • 1,806
0 votes
1 answer
122 views

Conditionally run function based on custom meta value?

I’m looking for a way to conditionally display an image within certain Woocommerce hooks that I choose based on whether a value is true within a custom meta field for the products on my site. For ...
positivecharge's user avatar
0 votes
1 answer
55 views

What snippet do I need to type to show my ACF field show up on my theme?

I've been trying all kinds of things but I can't get it to work cuz my Theme single.php looks different that usual. I made a field in ACF named Region and then enter for example USA which I need to ...
Space Money's user avatar
0 votes
0 answers
163 views

Insert Custom Field Value

I want to insert custom post type with it's custom fields values I have found this method to insert custom post type but with no custom fields wp_insert_post( array $postarr, bool $wp_error = false, ...
askuserahmed's user avatar
0 votes
0 answers
169 views

How to save HTML data into SQL post_content column

I have a custom template file containing some HTML tags and get_post_meta function. I want to insert the HTML data into post_content column. Is there a wordpress function or SQL function to save into ...
Morty_Smith's user avatar
0 votes
1 answer
133 views

delete duplicates wp_postmeta

I'm looking to cleanup wp_postmeta. I've found dozens of duplicate entries. I've spend about 8 hours looking through topics and trying code and plugins to no avail. The most useful article on the ...
Daniel's user avatar
  • 1
0 votes
1 answer
143 views

Format meta_value [closed]

I have a request to get postmeta records with a specific meta_value. global $wpdb; $result = $wpdb->get_results ( " SELECT * FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key LIKE '...
Suzan's user avatar
  • 3
0 votes
0 answers
40 views

How can I query for posts using a date stored in post-meta?

I’m working on a games release feature for a website I’m building. So far everything is going smooth, but I’m stuck on one area. For the listings on the front end, I want it to look at the “...
M. Straw's user avatar
  • 119
0 votes
2 answers
275 views

Next/Previous Product with custom order by price & products inside the product category [closed]

How to create next/prev buttons that are price sorted and give results inside the product category you are in? This question has been asked multiple times and despite the multiple threads there wasn't ...
John Aps's user avatar
0 votes
1 answer
66 views

Is there a way to make [Table Of Content] plugin while not using revision data?

I have a problem while using TOC plugins 'cause all of TOC plugins use revision data to recognize header tag. I'm using my own metadata (custum field) plugin and the data doens't show on the revision ...
Morty_Smith's user avatar
0 votes
0 answers
69 views

Why is $_POST empty when saving custom Meta Box?

I'm creating a Meta Box in my custom Plugin where the Administrator can select which users can view a certain post based on their roles. When I select the role and save the meta box content by ...
user3716433's user avatar
0 votes
1 answer
103 views

How to check post meta isset or not empty during publish/save post?

How to check if a specific post meta isset/!emtpy during updating or publishing a post ( save_post() )?
Amenadiel's user avatar
0 votes
2 answers
59 views

How do I check if an article is popular this week?

I use this function to set and get post view of post in my WordPress function wpb_set_post_views($postID) { $count_key = 'wpb_post_views_count'; $count = get_post_meta($postID, $count_key, ...
jimi-del's user avatar
0 votes
1 answer
30 views

how to show records that don't have custom meta value

Running pre_get_posts, I want to order the items by a custom meta value. The problem is that by default this doesn't exist. Only if a user performs a certain action does the meta key/value get added. ...
user8463989's user avatar
0 votes
0 answers
564 views

SQL query - get a featured image's alt / alternative text

I am writing some SQL queries to get post data out of a database for certain posts (so WP functions are not an option). I am trying to get post IDs, post URLs, post featured image URLs and associated ...
Anthony's user avatar
  • 31
0 votes
0 answers
600 views

How to change text color depending on the number value (Using javascript)

I'm trying to change text on the table depending on the meta value I give (number). if meta value >= 7, number text on table changes to green. else if meta value >= 4, number text on table ...
Morty_Smith's user avatar
0 votes
1 answer
734 views

how to get serialized post meta

I have posts that have video content and these videos stored in database like this (serialized) a:1:{s:9:"video_url";s:0:"";} This serialized data have post video urls but can ...
Teymur Abbasov's user avatar
1 vote
0 answers
123 views

Using hook to use DISTINCT in a wp_query

SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) INNER JOIN wp_product dg ON dg.post_id = wp_posts.ID AND ( dg.location IN ('XV', ...
Sayaman's user avatar
  • 135
0 votes
1 answer
77 views

Save all the post tags inside a custom field

I'm having some trouble to add_post_meta using the code below with all the post tags inside a custom field. The code works to echo all the tags, but not for saving them because it only saves the first ...
bpy's user avatar
  • 299
0 votes
1 answer
2k views

update post meta value with other post meta value

I'm a beginner in wordpress / php trying to learn. I want to use the update_post_meta function to populate one meta value (X) with another meta value (Y) everytime Y is changed. I did research and ...
Jawequo's user avatar
0 votes
0 answers
123 views

get value from get_post_meta then reuse it in another get_post_meta

I am writing the following code, which I have updated since the original question so as to give the entire picture. I am a newbie, and the reason why I am not using the get_posts() function in ...
luke_mclachlan's user avatar
1 vote
0 answers
81 views

How do I create an archive page as a <table> including metadata?

I'm really struggling getting this seemingly simple thing to work. I have a list of "vendors" as a CPT. They have metadata like "contact name" and "last invoice date". I'...
nathanziarek's user avatar
0 votes
1 answer
72 views

update_post_meta() updating nested array in Multidimensional array with empty sub-array

How can i update/remove/empty a sub-array on user post submission in admin area? here ist the reference on how to update nested array i am using but it is not working if ( $post->post_type == '...
Gildas.Tambo's user avatar
0 votes
0 answers
220 views

Post Thumbnail missing when using webp format while sharing

I have a problem when I upload a featured image for my post in jpg format, I get the featured image's thumbnail while sharing my post through any kind of messenger e.g whatsapp etc. But when I try to ...
bilalarshad24k's user avatar
1 vote
0 answers
25 views

Plugin with action 'save_post' needs to press publish twice on order to publish

I have an old plugin, which used to work fine (years ago). Now I have to press publish twice to publich the post. The problem is in the blocks below. The used variables are declared above the code ...
lassec's user avatar
  • 11
0 votes
1 answer
56 views

get specific values from WordPress meta_value

a:1:{s:9:"toys_item";a:1:{s:16:"toys_item_ranger";a:11:{i:0;s:31:"2 x Seadoo GTX 230/IBR Jet-Skis";i:1;s:30:"1 x HD Runway 10′ Waterslide";i:2;s:14:"4 x F5 ...
Pardeep Kumar's user avatar
0 votes
0 answers
26 views

Post Publish date not display on Umaya Child themes

I can't find out the option of published date or modified date on my blog post. I write the this code <?php echo get_the_date() ?> but can't display the date. this is my blog post where I try to ...
Nasim Amjad's user avatar
0 votes
1 answer
56 views

How to merge the array values in foreach?

I have tried to get the checkbox values from postmeta field but cant merge the array into single result $get_info_contact = get_post_meta( $result, 'wpcf-society-info-contact', true ); $combined =...
mike's user avatar
  • 11
0 votes
1 answer
344 views

Use wp_handle_upload outside of a POST

I'm writing a script that will prefill my custom post type with posts. Each post has a file (zip or json) as post meta that has to be uploaded to the media folder. The problem is wp_handle_upload ...
wpdev215's user avatar
0 votes
0 answers
263 views

Check For get_post_meta on Author Archive Page

I've had a good look thru the Similar Questions for an answer and i'm looking to check if a value for a custom field key on single posts has been added using get_post_meta(); however i want to use ...
Brad Dalton's user avatar
  • 6,896
0 votes
1 answer
156 views

Is duplicate `_wp_attachment_image_alt` meta key allowed?

This line in my plugin: $wpdb->query("ALTER TABLE {$wpdb->prefix}postmeta ADD CONSTRAINT postmeta UNIQUE (post_id,meta_key(100))"); gives me the following error: [Duplicate entry '539-...
Artem's user avatar
  • 305
0 votes
1 answer
627 views

Which is faster wpdb & get_row or wp_query & ge_post_meta?

Im planning to make a private api and i was wondering which one should i use go for my datas. wpdb & get_row with my custom sql regular wp_query & get_post_meta() Im wondering if it's better ...
Amenadiel's user avatar
2 votes
1 answer
3k views

ACF: How to get the full field name (meta_key) by a field key?

In Advanced Custom Fields: Which function can I use to get the full meta key of a field by its field key? So, if I have a field with the name some_field and the field key field_sd54hfs5df: How do I ...
David Wolf's user avatar
0 votes
1 answer
148 views

Order category posts by last word of custom field

I'm trying to order a category page by the last word of a custom field that all of its posts have. The custom field represents a name, so the last word would be the last name. In the end, the posts of ...
ayyyT5's user avatar
  • 3
0 votes
1 answer
27 views

Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?

I am struggling to word this correctly, but we have a list of laboratory blood tests listed: Comprehensive Blood Panel Basic Blood Panel Liver Blood Panel Cholesterol Panel and many many more These ...
Barry Chapman's user avatar
0 votes
2 answers
29 views

How to create review point system for CPTs (many-to-many relationship)

I am working on a Wordpress project where I have movies, books and games as custom post types. Any logged in user can add stars(review points) to each of the CPTs. My way of implementing this was ...
usanzadunje's user avatar
0 votes
2 answers
91 views

Negative meta_query if storing multiple post_meta values with shared meta_key

WordPress supports storing multiple post meta values for a single post using the same meta key. For example one post can have multiple instances of meta_key 'pet' with meta_value 'cat', 'dog', and/or '...
John Ryan's user avatar
0 votes
1 answer
42 views

How to save EXIF metadata in WordPress database?

I have a function that gets retrieves image EXIF metadata and displays it on attachment edit page. function wp_read_image_metadata_exif( $file ) { if ( ! file_exists( $file ) ) { return false; } ...
J.D.'s user avatar
  • 1
1 vote
0 answers
43 views

Wordpress Rest API to call page data associate with custom meta

I have an ajax rest api called to retrieve certain page data, the call was success but it's come with blank meta, is there any workaround to call api associated with meta data along? var request = ...
Ben Koo's user avatar
  • 11
1 vote
2 answers
2k views

Gutenberg: How to display meta field data in the block frontend (save function)

I have some legacy meta fields in my post that I would like to display in my block. I found a documentation for settings meta fields but not how to display them. So I tried this: export default ...
Marc's user avatar
  • 675
0 votes
1 answer
169 views

After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel

Made s script that under certain conditions adds a new custom post to the database. All works fine. But there is a flow. After writing the post to the database with my script I can not extract it with ...
Mihail_OLARU's user avatar
0 votes
0 answers
41 views

Add a "custom field" to a category that can be retrieved when viewing the category page with get_post_meta

I usually set a custom field customdata for posts and pages, that I can obtain when rendering a page with this PHP code: get_post_meta(get_the_ID(), 'customdata', true) Is there a way to set a custom ...
Basj's user avatar
  • 85
5 votes
1 answer
365 views

Is there a way to extend WP_query so Custom Post Types can have properties?

Having trouble finding info on this. When working with lots of metadata/custom fields, I would really prefer to simplify getting the meta data inside of templates instead of using get_post_meta and ...
liquidRock's user avatar
0 votes
0 answers
80 views

How do i create a custom post query when the meta value is an array?

A number of properties have been imported from an external API and saved into a custom post type called 'Properties'. I want to filter these properties by the city they are located in, however it is ...
Zeus7's user avatar
  • 1
0 votes
2 answers
315 views

Mass SQL Wordpress Meta Key deletion

hi i am newbie with SQL data base so forgive my dumbness i have installed KK Star rating plugin on my wp site which noticed its recording lot of entries and my db size is over 280 MB and 188MB is ...
Persian Prince's user avatar
0 votes
2 answers
128 views

Does using custom taxonomy is more CPU efficient than using meta_data?

Ok, I hope I won't get downvoted for this being not a coding question, but I think this will benefit all who want to make their Wordpress projects more CPU efficient. Basically on the other questions ...
robert0's user avatar
  • 203

1
2
3 4 5
40