People who code: we want your input. Take the Survey

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
0answers
38 views

How can i set media attachments to the author of the post or page for already existed posts with attachments

I have been uploading posts for multiple authors in my site and the attachements (photos) are registered all in my account. Is there a way to set the attachements to have the author of the post ? I ...
1
vote
1answer
13 views

WP nonce field checkbox prints checked='checked' outside input field

I'm currently creating a custom post type in wich I want to add some custom meta boxes. All the fields just go as expected excepting a checkbox field wich prints on the html checked='checked' after ...
0
votes
0answers
16 views

insert metadata on title

I have this function add_filter('wp_insert_post_data', 'modify_post_title', '10', 2); function modify_post_title($data, $postarr) { $customer_name = $_POST['customer_name']; if ($data['...
0
votes
1answer
83 views

Strict comparisons problem when using boolean post meta

register_meta( 'post', 'my_boolean_meta_value', array( 'show_in_rest' => true, 'type' => 'boolean', 'single' => true, 'default' =...
0
votes
0answers
29 views

Custom meta fields and meta keys

I read that you should only use lowercase letters for meta keys for custom fields - is this true? I need to set up several custom meta fields for products, and I would like to use a capitalized first ...
0
votes
2answers
80 views

“Cannot use import statement outside a module” JS error while adding a custom meta block?

I am following the "Store Post Meta with a Block" guide from the official Block Editor Handbook to add a custom post meta block using the supplied sample code (below). However, the block ...
0
votes
0answers
29 views

Why is the actual number of thumbnail images not matching what is store in an attachments metadata?

Occasionally my plugin needs to delete an image and its thumbnails images. However sometimes there is a discrepancy between the number of thumbnails an attachment has and the number of thumbnail files ...
0
votes
0answers
17 views

Disable preview button when post already publish

Hi is there any functions that we can use to remove the preview button after the post is published? What I need is when post never published yet, the preview will available there, but when you already ...
0
votes
1answer
4 views

Custom column on CPT not showing correct value when meta data not set

Basically I have 2 custom columns in the 'edit.php' of my custom post type. What I need is when $item_type is set to 'page' but there is no page selected, 'No selection' is echoed (same for when '...
0
votes
1answer
105 views

How to use multiple Meta Field from CPT as Post permalink

i have created a custom post type using Jetengine called "cars" and meta field like this "model" "maker" "year" .. etc, what i want is to use more than one meta ...
0
votes
2answers
29 views

get_post_meta shortcode returns empty field

I'm trying to create a custom shortcode that will allow me to input custom order field data into an auto generated outbound email template via the Custom Order Status for WooCommerce plugin. My ...
0
votes
0answers
17 views

Update Pages ONLY from Stage to Live (not products)

I have a WordPress site that has a bunch of posts, a bunch of pages and a bunch of products (Woocommerce ones). I Staged the site and made loads of changes to the pages on stage, meanwhile the live ...
0
votes
0answers
13 views

update_post_meta() inside “save_post” hook doesn't save to database - only through REST API

I have a function that is being called whenever a woocommerce product is published (through the save_post hook). This function uploads a few images, attaches them to the current post being saved (...
-1
votes
1answer
20 views

How to save custom made object in an array in a post meta field

I've made two custom classes: FooBar BarSchizzle I'm making a quite custom calculation of a bunch of things, that I would like to save in an array in a post_meta field. This is how I save it $obj1 = ...
0
votes
1answer
13 views

WP API Response does not show my registered metadata

I am trying to get metadata from a custom post type splash_location however it's not showing up in my response. I have registered my metatag splash_location_title but it doesn't show up in my JSON ...
0
votes
0answers
22 views

Display Custom Post Types & Post Meta in iCal

i'm a real noob so please go easy. I'm trying to edit something i found online, but with minimal knowledge. I'm sure i'll get told that i've done it totally wrong, but i'd rather try than just ask how ...
0
votes
1answer
36 views

How to modify the output of wp_terms_checklist when used within the built-in category metabox on edit posts?

On the Edit Screen in the WP Admin there is a meta box for WP's built-in Category taxonomy. This meta box is built using post_categories_meta_box() (/wp-admin/includes/meta-boxes.php). This meta box ...
0
votes
0answers
9 views

Add post_meta while uploading or editing image of custom post type

with this function i add post_meta's while uploading a feature image to a post add_action('added_post_meta', 'wpse_20210426_after_post_meta', 10, 4); function wpse_20210426_after_post_meta($meta_id, $...
0
votes
1answer
38 views

Adding Custom Metadata to my Archive/Posts page

I am currently working on a news website and using the Wordpress archive feature to display all my posts in a feed (when you click on the post titles you are taken to the source website).I need to add ...
0
votes
0answers
18 views

How to save custom fields' value whenever they change with timestamp?

I have created two custom fields for posts - post owner and post assignee. I want to check the chain of possession throughout the existence of that post along with the timestamp. But, I'm unable to ...
0
votes
1answer
20 views

How to update custom fields when post is published?

I've created two custom fields on the post edit screen using the ACF Pro plugin. If the fields are empty, I want to set the current user as both the field's value when the user clicks Publish button. ...
0
votes
1answer
21 views

Avoiding ACF get_field and returning to core Wordpress function

function slb_subscriber_column_data( $column, $post_id ) { // setup our return text $output = ''; switch( $column ) { case 'title': // get the custom name data $fname = ...
0
votes
1answer
26 views

Why ever use add_post_meta, and not just update_post_meta?

I stumbled across this nice guide on Smashing Magazine on how to add a custom meta box. In there, I can see this code here, which has me puzzled: /* Save the meta box’s post metadata. */ function ...
0
votes
1answer
20 views

How to check if a post meta key/value pair already exists for a specific post

I want to know if for a given post ID $post_id, there is a metadata key and value pair stored that matches a given key $meta_key and value $meta_value pair. I am not looking for ANY post that matches ...
-1
votes
1answer
20 views

Remove action of an external plugin after checking if custom post meta is set

Edit:The problem were 2 folds - somehow the order list I found before indicated wp_head was before wp_enqueue_scripts but that is not the case. Found another more updated one and it is actually right ...
0
votes
0answers
21 views

Update Images after edit via php

After editing images directly inside the upload folder via PHP-functions, I managed to automatically regenerate the meta data, the thumbnails and the WebP copies. (Checked via FTP! Even the displayed ...
0
votes
0answers
13 views

How to make two different meta fields look for same thing

I am new to WordPress and working on an events management website. I am using a theme that looks for events data using some specific meta fields for e.g. event_start_date for start date of the event. ...
0
votes
1answer
26 views

How to access post meta on the first time a post is published

Am trying to send an email based on the contents of a post published but it should only be done if its the first time the post is published. Therefore am using add_action( 'transition_post_status', [ $...
0
votes
0answers
16 views

add datepicker to post edtor

I've created a wordpress headless installation that rely on vuejs and REST api for the front-end. I need to add into the classic editor a datepicker to give the user the ability to select a date that ...
1
vote
1answer
34 views

How to get all term meta for a taxonomy - getting term_meta for taxonomy

TL;DR: I'm trying to get the meta_value display_type for a taxonomy, but it returns blank (even though I can see it in the database). This question wants to access a term meta that is on a the ...
0
votes
0answers
9 views

Creation of a search page and event display with datepicker metaboxes

Being a beginner in the development of Wordpress theme, I'm currently trying to create a custom search filter on a dedicated event search page template. For this, I created custom fields of date ...
1
vote
0answers
24 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> ...
0
votes
0answers
9 views

Custom Post type editing: where has my publish button disappeared?

I run a Wordpress website with a lot of Custom post types, where I customized the interface so that contributors can easily do what they need. When editing a given post, widgets appear on the second ...
0
votes
1answer
11 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 ...
0
votes
1answer
24 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 ...
1
vote
0answers
22 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 ...
1
vote
1answer
25 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 ...
0
votes
0answers
35 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['...
0
votes
0answers
15 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. ...
0
votes
0answers
18 views

How to delete post meta array by value

I have three fields I am saving as an array to a custom post meta. Like such... <label>Member:</label><input name='cantcommit[mbr]' value='' /> <label>Arriving:</label>&...
3
votes
1answer
71 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- ...
1
vote
0answers
22 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 ...
0
votes
1answer
22 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 ...
0
votes
0answers
16 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 ...
0
votes
0answers
36 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 ...
0
votes
0answers
18 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="...
0
votes
0answers
18 views

WooCommerce query produces out of stock products - Hide out of stock option ON

So, I've this website where I've set option in WooCommerce settings to hide out of stock products. When I load product category on the frontend, I get something like: showing products 1-16 of 350 ...
0
votes
1answer
30 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 ...
1
vote
0answers
32 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, ...
1
vote
0answers
52 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 ...

1
2 3 4 5
38