Questions tagged [post-meta]

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

600 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
1 answer
2k views

Admin Area Custom Type Search By Meta Fields Without Title & Content

I have a custom post type that uses several meta fields. In the admin area I would like to be able to search by those meta fields. I have implemented this currently in my functions.php with this code: ...
user1117841's user avatar
4 votes
1 answer
1k views

get_post_meta returning empty string when data shows in the database

I'm absolutely stumped and I'm hoping this is something stupid that I just can't see because I'm too close to it. Working on an LMS using Sensei. Trying to get the course_id from a lesson. Pretty ...
James Meyer's user avatar
4 votes
1 answer
399 views

publish_post action hook doesn't give post_meta_data

I write the following function to get the post data on publish post but i see that post_meta is not available, its always empty. How do i retrieve the post meta data of a post on publish_post hook? ...
deepthi shv'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
3 votes
0 answers
2k views

Correct processing of `$_POST`, following WordPress Coding Standards

Background I'm building a project that according to the specifications need to follow the WordPress Coding Standards. I am using phpcs to scan my code. If I try to pass $_POST-data into a function ...
Fabian Mossberg's user avatar
3 votes
0 answers
222 views

How to save a ToggleControl value in a meta field?

I registered a boolean meta field called _meta_restrict in a custom post type: PHP: function register_meta_fields() { register_post_meta( 'custom_post_type', '_meta_restrict', array( '...
leemon's user avatar
  • 1,806
3 votes
0 answers
1k views

ACF Upload Image in repeater from front-end with custom form? - add_post_meta()

I want to upload images in the ACF repeater. That repeater means the gallery of page. Point is to create post in custom post type using add_post_meta() method. Here I have the form : <input type=...
Milosh N.'s user avatar
  • 195
3 votes
0 answers
884 views

How to use pagination with get_post_meta

I have a Products Page that i am using to add products using custom metaboxes this is the code for my page <div class="container products"> <div class="row"> <?php $...
Mohamed Mokhtar's user avatar
3 votes
0 answers
3k views

Copying Custom Meta Values from existing post to a duplicate post

I'm trying to revise an existing WP plugin BU Versions to accept different custom meta field values from items I've set-up using the Advanced Custom Fields (ACF) plugin. BU Versions will copy over ...
unwrittendevin's user avatar
3 votes
2 answers
6k views

Displaying Meta Box Image

I have some problems displaying info from my custom meta box in my custom post type single. I'm using Reusable Custom Wordpress Meta Boxes by Tammy Hart. I'm able to display the textfields using this:...
turtledropbomb's user avatar
3 votes
1 answer
655 views

Change post format using custom field

I'm creating a theme using the CF Post Formats plugin. But I've run into some trouble I don't know how to solve. Here's what I want to be able to do: Create a new standard-format post Enter a url ...
Herbie's user avatar
  • 31
2 votes
0 answers
317 views

How to store Gutenberg ColourPicker RGBA as metadata

I'm trying to build a sidebar plugin for Gutenberg which uses the ColorPicker component to store a chosen rgba value in metadata using withSelect and withDispatch (I'm testing below with the hex value)...
Sean Varnham's user avatar
2 votes
0 answers
155 views

How to remove get_post_metadata using remove_filter inside a class?

This is the filter that i use. add_filter('get_post_metadata', array(WPKWP::CLASS_NAME, 'get_post_metadata'), 10, 4); I have to use the get_metadata inside the above call back function. If I use ...
user avatar
2 votes
1 answer
626 views

How to change ID of an attachment in wp_posts and its related tables correctly?

I have two posts in my wp_posts table where post_type='attachment' The picture below shows the records related to those in wp_postmeta table I need to change the IDs of those files. What I am doing ...
Eray Balkanli's user avatar
2 votes
2 answers
69 views

How to use a Term Meta Field as a link

I created a taxonomy called animal and a term meta field called horse. I created a function in my functios.php file to make it easier to display the data. Here is my code: function ...
jweb's user avatar
  • 21
2 votes
0 answers
286 views

Query Posts depends on custom field inside repeater field using acf

i am working on a hotel website and trying to make price search i have custom post type name hotels inside post type i have a repeater field inside repeater i have some rooms with prices i am ...
Wael Mahmoud's user avatar
2 votes
0 answers
1k views

Is it possible to update a post meta field through REST API if the format of it when registered is nested?

I am able to get the custom REST API fields using meta key values to be formatted like this: "location": { "lat": "000001", "long": "000002" }, The works fine when I am trying to retrieve ...
drifter's user avatar
  • 243
2 votes
0 answers
2k views

Metabox not show in categories custom post type cmb2

it is possible to add a field in the categories (tags) in taxonomy? this is my code in functions.php function post_types(){ register_post_type('products',array( 'labels' =&...
Max's user avatar
  • 53
2 votes
1 answer
117 views

Which is best in the following scenario : post_meta vs custom table vs parent/child posts

I’m looking for a bit of advice on which way to go with a development question. I’m building a community site where subscribers create their own private posts. The data they enter falls into two ...
Mick R's user avatar
  • 21
2 votes
1 answer
1k views

How trigger to save post when updating post meta

I have very confused situation. I have added posts and all posts metas from one website db to another one, everything is fine, images, title, description of posts are there. But post metas are not ...
Anna Gabrielyan's user avatar
2 votes
0 answers
1k views

Add multiple attributes to product from php

I'm trying to update a WooCommerce product entry with data from an API, where the values from the API match taxonomy terms I've created in my WordPress site. For most fields this works, but I have ...
Jan Henckens's user avatar
2 votes
1 answer
1k views

get_post_meta fails after switch_to_blog

I have some code for custom cron in wordpress multisite, that from each blog site, gets their posts and postmeta data and put them on an xml structure. But, when I retrive metadata (using ...
TorryVic's user avatar
  • 153
2 votes
0 answers
2k views

get_the_terms() to show all custom taxonomies

I have created three custom taxonomies that categorize my post types by project-client, project-brand, & project-medium. As of now I can use the get_the_terms() function to return only one ...
WeebleWobb's user avatar
2 votes
0 answers
1k views

Button inside Custom Meta Box triggering the Update Button

I have a custom meta button that adds additional custom meta fields inside the custom meta box. This meta box, in particular, gives me a choice to enter a particular skill and rate my own ...
Migs M.'s user avatar
  • 33
2 votes
1 answer
249 views

Efficient way to save a lot of meta data

im currently developing a plugin that will read an external xml, and convert the data to a custom post type. Each post needs around 50-60 meta_fields. Right now im looping through each piece of needed ...
Malibur's user avatar
  • 579
2 votes
1 answer
4k views

Saving custom image meta fields

I have currently added a custom meta field to upload a media file (image). I can successfully add the upload button to display and it works but I'm having problems saving the field when updating the ...
rikardo85's user avatar
  • 127
2 votes
0 answers
457 views

Querying posts with meta value that begins with a certain pattern

I am trying to create a search filter using meta_query. The only problem I'm having now is that I can't compare with wildcards. I think that's how you word it? $keyword = 'sos'; $tlds = array('com','...
naruzshadow18's user avatar
1 vote
0 answers
20 views

Wishlist Icon in Divi Blog module (loop)

I use the Divi Blog module (loop), but it lacks some functions. So with a childtheme and code I retrieve post meta in the Divi Blog Module, thats all working fine. But, I also want a working wishlist ...
Joyce's user avatar
  • 11
1 vote
1 answer
23 views

What is the best way to get a different post's custom field/postmeta with js?

In gutenberg I want to get a postmeta (it's a json string) that belongs to post #123. I want to check the editor's content against it. Let's say that postmeta's key is "blocks". So I made ...
user18102663's user avatar
1 vote
0 answers
28 views

Extend file format support for post thumbnails

I am trying to enable video thumbnails for posts in my theme. I created a custom post thumbnail media uploader in an editor plugin as follows (This is necessary, because the default uploader can't ...
TimMKuehle's user avatar
1 vote
0 answers
35 views

Post meta box data not saving

The meta box, fields, etc. are all displaying correctly but when I go to update the page it seems the data in those boxes has not saved. Any ideas? Using a custom post type called 'question'. Would be ...
Tom Foster's user avatar
1 vote
0 answers
97 views

Saving multiple custom meta box fields

So, I have a custom metabox, with multiple fields on it, and the amount of boxes is variable (could be 3, could be a lot more, depending on order quantity number) I'm trying to write a save function ...
Mark Tabner's user avatar
1 vote
1 answer
106 views

Generate metadata for cloud images

The current situation We use the AWS SDK for PHP to store media files on S3 instead of the server's local storage, and use the wp_handle_upload filter to point the inserted attachment to the S3 file ...
Jafar Abazeed's user avatar
1 vote
0 answers
125 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
1 vote
0 answers
82 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
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
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
0 answers
264 views

_wp_attachment_metadata is not being added to database when PDF files uploaded

When I upload a JPG or PNG image, a _wp_attachment_metadata value is created in the database, but this is not the case for PDF files. Is this the normal behavior or should the _wp_attachment_metadata ...
Joe's user avatar
  • 111
1 vote
0 answers
432 views

changing meta value and meta key of price field

I have theme that uses price field. its price is stored in "S1" meta key. next is woocommerce that use simple _price meta key to tore price values. i want that when user enter price in theme ...
Sundas's user avatar
  • 11
1 vote
0 answers
39 views

Posting to a Custom Post Type from front end - user generated content

Is there a fast and reliable way of posting to a Custom Post type from the front end? My use case is for creating a daily checkin for a fitness trainer. I have created the necessary fields using ACF. ...
thedamntrips's user avatar
1 vote
0 answers
38 views

Unset field from an array not working as expected

I'm trying to filter a custom options page from acf that is used to create menus based on items that are added on the backoffice, but I'm not being able to unset the fields when they aren't supposed ...
Rui Silva's user avatar
1 vote
0 answers
23 views

Read / Watch / Listen times - meta

I have a website organised around three kinds of posts (categorised accordingly): "Read" "Watch" and "Listen". I want to have a read-time and watch-time and listen-time ...
gravey123's user avatar
1 vote
0 answers
183 views

Update post_meta with WooCommere variation data

Iam having a product with multiple variations. I created custom fields which will show up in the settings of each variation. These fields should hold/duplicate some variation data. Iam having trouble, ...
LWS-Mo's user avatar
  • 1,522
1 vote
0 answers
71 views

What is faster: custom taxonomy or serialized post-meta for db retrieval? (over 60,000 posts)

I have a search plugin that can search serialized metadata as well as categories (for multi-checkbox). Is there any advantage to using serialized post metadata instead of creating a custom taxonomy ...
Benedict Harris's user avatar
1 vote
1 answer
39 views

Fetch Record based on meta key dates

I want to write a query which fetches the data based on my meta key added. Meta key name is 'repeater'. This is my POST META. Serialized: a:3:{i:0;a:3:{s:9:"postdates";s:10:"2021-02-02&...
aliasgar vanak's user avatar
1 vote
1 answer
364 views

How to add custom metadata text box dropdown to sidebar in Gutenberg editor for all post types

I am looking for how to add a custom dropdown on the right sidebar of the Gutenberg editor. I would like to do this within the functions.php of my custom theme, not with a plugin. The dropdown would ...
Sean's user avatar
  • 11
1 vote
0 answers
479 views

How to display the "ratingValue" and "ratingCount" values ​generated by the KK Star Ratings plugin into my page's recipe ld+json schema

I'm trying to add ld+json schema markup to each recipe page on my site that will automatically pull over the most up to date aggregator rating data (from kk star ratings). I came across this post (...
Kyle Doran's user avatar
1 vote
0 answers
309 views

Getting meta in editor plugin, and event triggering issue

I have a Custom Post Type defined with custom-fields support. I then registered a meta field. The first issue is that select( 'core/editor' ).getEditedPostAttribute( 'meta' )....
Laurent's user avatar
  • 214
1 vote
0 answers
215 views

WP_Query with meta_query for children

I'm using WooCommerce and it has a lot of plugins to handle different stuff. The one thing needed by the client that no other plugin manages correctly is which variations can be visible for each user ...
ZioCain's user avatar
  • 111
1 vote
0 answers
58 views

Sort custom meta column by other meta value

I have a post type named "event" and I store two meta values for these posts: _start_time and _start_time_unix. The first one contains a string representation of a date and the other one a ...
wwdes's user avatar
  • 11

1
2 3 4 5
12