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
1 vote
0 answers
386 views

Limit the number of acf content when displaying in post loop [closed]

I display post images by this way in the loop . <?php $images = get_field('POST-IMAGES'); $size = 'medium'; // (thumbnail, medium, large, full or custom size) if( $images ): ?> <ul> ...
Teymur Abbasov's user avatar
0 votes
1 answer
326 views

How to detect that the save_post hook is calling the callback associated to the current edit post page only

I am using the save_post hook to handle updates in a post that are done via the admin edit post page. But since I have more than ten custom post types, the save_post associated to each one of them is ...
Álvaro Franz's user avatar
0 votes
1 answer
783 views

Change post author without using wp_update_post()

The standard or more obvious way to change a post author in WP is to use the wp_update_post() function, as shown in this question. But I am having an issue, described as follows: // Inside the ...
Álvaro Franz's user avatar
1 vote
0 answers
425 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
1 answer
137 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 ...
Batuhan Aygun's user avatar
0 votes
0 answers
279 views

update_post_meta() is not saving the value

I have been working on this for hours already but cannot manage to find a solution. I am using this code to save a value for a metabox: $fecha_proxima_revision = sanitize_text_field($_POST['...
Álvaro Franz's user avatar
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
4 votes
1 answer
1k views

Should I sanitize custom post meta if it is going to be escaped later?

Firstly, sorry if this has been properly answered before. After reading a lot of questions and guides, I'm still not totally convinced on the best way of doing things. I understand the basics of XSS- ...
Tysss's user avatar
  • 43
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
0 votes
1 answer
83 views

Only show meta on one post type on search results page

I want to remove the post meta from all post types that are not "posts" from my site or at least from the search results. Im currently using the Jnews theme and in the search results page I ...
Jean X. Santiago Santana'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
0 votes
0 answers
46 views

Add an action based on custom post meta field

I need to add every single post as a custom hook, in every post I have tow field, mycode will be code content and need to hook it to custom action, this custom action Ill get it from ...
Jlil's user avatar
  • 222
0 votes
0 answers
28 views

Save data is post using php front end

I'm newbie, i have a simple php file ,there is my data like, title, body content, feature image, category and 1 custom file I want to save this data in my post My coding look like this $title="...
Muhammad byeim's user avatar
0 votes
1 answer
176 views

Ajax: Populate <div> with content from a post's ID not working - duplicating current page html instead

Ok guys and gals, I'm losing my mind here... I am looking to append the content and a custom field of a post to a div on page. The ID of the content and custom field is defined by a data attribute on ...
richerimage's user avatar
1 vote
0 answers
173 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
4 votes
1 answer
547 views

How Can I save multiple records in same meta key?

I want to save multiple dates in meta key. I have a three dates 2,3,4 and I want to save all these values in same meta key but as a different values. For example: dates(meta key) 2(meta value) dates(...
aliasgar vanak'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
0 votes
1 answer
17 views

Branch made by several custom values

Below code from function.php works fine when the custom value used for conditional branch is only one. This code means if custom key A is AAA, update custom key B as ZZZ. if(get_post_meta($post->ID,...
cwhiro's user avatar
  • 25
0 votes
1 answer
42 views

How to improve my non-unique metadata MySQL entries?

I'm working on a plugin for WooCommerce which uses a cpt called Restock. In a Restock post you can enter products ( id ) plus restock. The user can add as many product restock pairs as they want per ...
photogenic's user avatar
1 vote
1 answer
357 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
0 votes
2 answers
1k views

register_meta not showing custom post type metabox data in rest api

I have added a custom post type and I want to expose the custom field value in the rest api. As per the docs register_meta can be used. I have created a custom post meta box using the wordpress way. ...
user avatar
0 votes
0 answers
73 views

Removing Malware

I've been asked to remove some Malware from a friend's site. I've found some wonky links in the wp_postmeta table, but the post_id that the field is associated with doesn't exist - and, weirdly, it's ...
datakid's user avatar
  • 101
0 votes
0 answers
446 views

Cannot edit post meta fields with rest API

I am using python to send POST requests to /wp-json/wp/v2/< post type >/< post id >. This successfully updates standard fields such as title, content etc. However I am unable to make any ...
D10001's user avatar
  • 1
5 votes
2 answers
6k views

Add post meta fields, when creating a post using WordPress' REST API

In the documentation for /posts for WordPress REST API it states that I can add a meta-field. But it doesn't say which format that should be in. I can find other guides showing how it should be if ...
Zeth's user avatar
  • 828
1 vote
1 answer
152 views

WP_POSTMETA changes site crash

I try to update wp_postmeta from SQL script. This is my original row in table: a:7:{s:16:"lambda_page_item";a:24:{i:0;a:9:{s:9:"grid_size";s:3:"940";s:7:"boxname&...
Joe Taras's user avatar
  • 113
1 vote
0 answers
477 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
0 votes
1 answer
38 views

I Can't get the post_tag name from term_id using wp_set_object_terms

I use https://rudrastyh.com/wordpress/select2-for-metaboxes-with-ajax.html. I want to display the name of post_data inside widget tags of posts and mainly tags column inside posts list. I can't get ...
imagIne's user avatar
  • 41
1 vote
1 answer
342 views

Update Post Meta for a logged in user

I have created a form which collects information which I want to update a post with. The code I have works great, but instead of updating a post for the user, it creates a new one. Not sure what I am ...
sodanotpop's user avatar
1 vote
0 answers
307 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
0 votes
1 answer
71 views

how to auto random increment for post view

i want edit this code to auto increment not just +2 for each user's click and instead increment number would be random ( + 2 , + 4 , ... ) if( $should_count && ( ( isset( $views_options['...
samanta's user avatar
1 vote
0 answers
213 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
0 votes
1 answer
22 views

Set class if a meta value is set within post archive

I'm attempting to add a class to posts when the meta key 'checkbox' is clicked. Here's what I have: <?PHP $checkbox = get_post_meta($post->ID, 'checkbox', true); if (!empty($checkbox)){ $...
Camille Roney's user avatar
0 votes
0 answers
959 views

How to register post meta with multi level arrays?

I'm tringing to register post meta with object options under main object trim_levels to be used with REST API. register_post_meta('vehicle', 'trim_levels', [ 'type' => 'array', '...
Edgar's user avatar
  • 1
0 votes
1 answer
206 views

Sort by price wpdb

I have a page on my wordpress to search for tires everything works fine but I would have liked to know how to add an extra column to sort them also by price. They can already be sorted by size and ...
Mourcely Quentin's user avatar
0 votes
1 answer
133 views

Ordering posts by anniversary using only day and month

I defined a custom field named crimedate using standard date format Y-m-d. I defined the filters to make ordering by this date work in the post list of the backend, which works fine. Now I need the ...
geraldo's user avatar
  • 145
0 votes
1 answer
299 views

Do posts, pages and / or custom post type objects have unique ID numbers or can there be multiple objects with the same IDs?

What are the canonical rules for the ID numbers of posts, pages and CPTs? Especially as they are created programatically.
John Dee's user avatar
  • 503
0 votes
1 answer
309 views

Ordering posts by custom field named "date" in backend

I defined a custom field named "date" and now want to order the post list in the backend by this field. I defined the filters to make ordering work and header is clickable and shows the ...
geraldo's user avatar
  • 145
0 votes
1 answer
440 views

What are the meta fields for an attachment?

I'm trying to find all the meta fields that are used for an attachment: like Title, alternative text, description and caption . I've looked all over and the only one I was able to find was for an ...
Gregory Schultz's user avatar
0 votes
0 answers
51 views

Meta query ignores multiple values of the key

I have the following post meta for posts: _post_allowed_countries //Example value: array ( 0 => 'en', 1 => 'gr', ) // A list of allowed countries and _post_allowed_countries_not //Example ...
DimChtz's user avatar
  • 177
0 votes
1 answer
168 views

How is the author's name given a different color?

Author's and visitors' names use the same color in comments.The point here is that the color of the author's name is different in the comments. For example, in visitor comments, name is red. But, the ...
A. Muller's user avatar
0 votes
1 answer
385 views

Trouble with serialized metadata

I've read about 20 different posts on this topic and I still can't apply the solutions to the problem I'm having. I'm very sorry for not being able to figure it out based on those answers, but I ...
Lorn Waterfield's user avatar
0 votes
0 answers
127 views

How to get posts by meta value as multi-dimensional array?

I know how to get posts by a specific post meta when the meta value is a string. $meta_query = [ [ 'key' => $meta_key, 'value' => $meta_value, 'compare' => '=' ...
J.BizMai's user avatar
  • 820
1 vote
1 answer
185 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 ...
curiousjake's user avatar
0 votes
1 answer
475 views

No more get_option('date_time') in Wordpress 5.5?

The template I'm using outputs the date of a post using: echo get_the_date( get_option( 'date_time' ) ); I was wondering why this output is now (after upgrade to WP 5.5) not working anymore? A fast ...
wittich's user avatar
  • 173
0 votes
1 answer
782 views

Unable to gather Image URL from Custom Post Type's; Custom Meta Field

I have wrote a very basic plug-in, it creates a Custom Post Type (CPT) that has multiple custom meta fields. I cannot seem to echo out the Image URL. I have tried a heck of a lot of other similar ...
Jason Is My Name's user avatar
0 votes
2 answers
19 views

How to keep custom post type related information

I have two custom post types "Product" and "News". I want to keep a description that describes each of these types and I want to display it under the custom post title inside a ...
xandar6's user avatar
0 votes
1 answer
27 views

Adding custom meta boxes to specified custom post type

In previous situations I have been able to add a custom meta field to posts, the code was this: function website_add_meta_box() { add_meta_box( 'website-website', __('Website', '...
Jason Is My Name's user avatar
0 votes
1 answer
268 views

Update wp_postmeta table based on 2 keys

I want to update the wp_postmeta table in the database based on 2 keys, is there a way to do that using any of the wordpress default functions. This is my DB query which is working fine: $sql = "...
H_alt's user avatar
  • 3

1 2 3
4
5
40