Questions tagged [post-meta]

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

597 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: ...
user avatar
4 votes
1 answer
903 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 ...
user avatar
4 votes
1 answer
376 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? ...
user avatar
4 votes
1 answer
633 views

Query Custom Meta Value with Increment

I have a Query searching for a meta value I have added to my posts (meta-select). I have it feeding out in a loop with 4 results. Let's say I want this loop to start with the meta value "2" and work ...
user avatar
  • 43
3 votes
0 answers
65 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 ...
user avatar
3 votes
0 answers
908 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 ...
user avatar
3 votes
0 answers
886 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=...
user avatar
  • 165
3 votes
0 answers
858 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 $...
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 ...
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:...
user avatar
3 votes
1 answer
589 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 ...
user avatar
  • 31
2 votes
0 answers
137 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( '...
user avatar
  • 1,637
2 votes
0 answers
275 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)...
user avatar
2 votes
0 answers
109 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
422 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 ...
user avatar
2 votes
2 answers
47 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 ...
user avatar
  • 21
2 votes
0 answers
260 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 ...
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 ...
user avatar
  • 223
2 votes
1 answer
107 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 ...
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 ...
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 ...
user avatar
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 ...
user avatar
2 votes
1 answer
227 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 ...
user avatar
  • 569
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 ...
user avatar
  • 119
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','...
user avatar
1 vote
1 answer
38 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 ...
user avatar
1 vote
0 answers
14 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', ...
user avatar
  • 11
1 vote
0 answers
28 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'...
user avatar
1 vote
0 answers
17 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 ...
user avatar
  • 11
1 vote
0 answers
31 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 = ...
user avatar
  • 11
1 vote
0 answers
181 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 ...
user avatar
  • 11
1 vote
1 answer
44 views

Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)

I mean; There are more than 7000 posts. some have private space but some do not. I want to add a custom field in bulk to those that do not contain custom fields and update their values. The following ...
user avatar
  • 21
1 vote
0 answers
27 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. ...
user avatar
1 vote
0 answers
27 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 ...
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 ...
user avatar
1 vote
0 answers
92 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, ...
user avatar
  • 1,434
1 vote
0 answers
69 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 ...
user avatar
1 vote
1 answer
30 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&...
user avatar
1 vote
1 answer
136 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 ...
user avatar
  • 11
1 vote
0 answers
235 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 (...
user avatar
1 vote
0 answers
173 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' )....
user avatar
  • 212
1 vote
0 answers
132 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 ...
user avatar
  • 111
1 vote
0 answers
30 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 ...
user avatar
  • 11
1 vote
1 answer
60 views

Store array as single, serialized post meta field or many post meta fields?

I am currently building a Wordpress plugin to fulfil WooCommerce orders for a "virtual" product. Once the payment is confirmed, I make an API call that returns a large (~50 values) array of ...
user avatar
1 vote
0 answers
263 views

A better way to add a meta box to custom post types

Id like to customize the UI for adding and editing a custom post type such that each custom field is included as a separate input field on the "new post" and "edit post" forms (as ...
user avatar
  • 21
1 vote
1 answer
176 views

Dynamic tagged image galleries

I'm creating a website for a theater company, using Elementor, ACF, CPT UI, and Jet Engine. One custom post type, "productions," includes an ACF gallery of production images. Another Custom Post Type,...
user avatar
1 vote
0 answers
49 views

How do I Implement Atomic Update of Post Metadata?

I'm building a site in which my logged-in users can "love" and "collect" posts. The number of loves and collects are stored within the post metadata using get_post_meta() and update_post_meta(). ...
user avatar
  • 11
1 vote
1 answer
306 views

How to display singular form of category name?

I have the following code to show the names of the categories for a single post. My categories are named in the plural (i.e. articles, letters, translations, commentaries, etc.), but in this function ...
user avatar
1 vote
1 answer
665 views

How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)

Sorry guys, had to post this again as site wouldn't let me respond to comments (new account). I have been working on some code to decrease quantity of a variable product based on the numeric values ...
user avatar
1 vote
1 answer
231 views

Add a date updated/date modified option using custom fields

I run a news website, and I think there are considerable benefits to adding a last date updated option to it. However, everything I see online is for replacing the published date with the date ...
user avatar

1
2 3 4 5
12