Skip to main content

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
866 views

post_name is not stored until post is published... where should I store my slug until it goes live then?

important try as normal contributor user, not as admin see here I actually have it reproduced. Seems like a bug to me but whatever. I want users to choose their slug. Well, as you cannot store ...
1 vote
2 answers
3k views

get_post_meta($post->ID) returns empty string when in preview mode of custom post type

I've got my custom post type 'event'. I got tne next code in single-event.php: get_header(); the_post(); echo '<pre>'; echo "$post->ID\n"; var_dump(get_post_meta($post->ID)); echo '</...
0 votes
1 answer
2k views

Allow HTML in Custom Metabox area

I know there are many questions related to my question, but sincerely i was unable to get solution. My question is simple, how can i allow html in textarea in custom metabox on post. So far i have ...
1 vote
1 answer
768 views

Hide author from search results meta, still display date and categories

How can I hide just the author from the post meta in search results, while keeping the date and categories? I know I can use something like: .post-meta .author { display: none; } to hide the author ...
0 votes
2 answers
2k views

WP cron and update post meta

I try to create a scheduled cron job which runs every hour, Its my first time working with wp-cron. In the cron function, I want to update post meta values, if some conditions are met. I also tested ...
0 votes
1 answer
1k views

get_post_meta not work in PHP foreach

I have these codes : require_once( dirname(__DIR__) . '/wp-load.php'); foreach ( $ids as $idss ) { echo get_post_meta($idss, 'IMDB', true); } I have search box with form element that search and ...
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 ...
0 votes
1 answer
1k views

How to get post detail based on URL of the post

I have a custom php page where I need to display details of a WordPress post based on the URL entered from the Admin. In the Admin, when adding the project detail, we enter few URLs of article post ...
1 vote
1 answer
1k 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 ...
0 votes
1 answer
987 views

Categorizing posts by location

I'm starting to work on a new project for which I will be using WordPress to facilitate content management. I have some experience building WordPress themes but it has been mostly related to page ...
0 votes
2 answers
1k views

Check if value exists before saving

I added an extra registration field: function wooc_extra_register_fields() { ?><p class="form-row form-row-first"> <label for="billing_cpf"><?php _e( 'CPF', 'woocommerce'...
0 votes
1 answer
1k views

Copy wp_postmeta from one database to another

I had a site setup on old-domain.com, which used the database old_db. Recently, we had to migrate our website to a new server and domain, new-domain.com which uses the database new_db. I installed a ...
0 votes
1 answer
1k views

Rename image filename using 'media_handle_upload'

I need to rename images uploaded by the user when they post on my site. I have a code that works perfectly to save the image and make it part of the post. But I want the images to be renamed to have ...
0 votes
1 answer
733 views

update_post_meta adding to array instead of replacing value

update_post_meta() keeps adding to an array instead of replacing value. Any tips? Previously I used add_post_meta() by accident and perhaps that somehow flagged the field as an array? Update So how ...
0 votes
1 answer
723 views

WP-API + JS Backbone client - how to update post meta

Using the WP API and Backbone-based JS client, I'm trying to update a post's metadata as follows: var parentId = 96; // the post id var metaData = new wp.api.collections.PostMeta('', {parent: ...
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 ...
0 votes
1 answer
401 views

After a while attachment meta data is missing "sizes" data

We like to use custom image sizes for custom WP themes. This way, we can provide appropriate images for the custom elements and we can ensure that images don't load too large or too heavy. Now we've ...
0 votes
1 answer
840 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
2 answers
756 views

How to return/export only data showing on screen in custom post type view all screen

If I for example filter my custom post type by date and it only shows 2 records on screen, I only want to export those 2 records, but it is exporting a bunch of records out of my control ie: the wrong ...
0 votes
0 answers
21 views

Optimizing storage of Post Meta Entries

I'm working on a WooCommerce site where each order needs to update financial and order count data for a specific center, which are stored as post meta in another custom post type named "event&...
6 votes
2 answers
14k views

How get post id from meta value

Please look at the picture below. I want to get post_id from meta_value = 93. How can I do that?
0 votes
1 answer
819 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 ...
0 votes
2 answers
1k views

post_title in save_post action

I use save_post action to save meta field and to check if post title is set. So I check the value returned by empty($post->post_title) but I get true also if I set the title.
0 votes
1 answer
1k views

Use WP_query to match post types based on custom field values

i'm trying to query posts from the post type Product that match with the current post in the loop from the post type Item, based on the custom fields product-ean and item-ean. For example: i have a ...
0 votes
1 answer
1k views

Metadata on the WP_Post object

I'm having trouble understanding the behavior of a WP_Post variable (and / or possibly the behavior of var_dump itself). As far as I know, var_dump will inspect all data from a variable. From the PHP ...
0 votes
1 answer
1k views

Blogposting Schema & Structured Data without plugin

I would like to add blogposting schema markup so each new post is automatically optimized for rich data. Some code on the web is messy and needs updates per each post, also plugin is not best option ...
0 votes
0 answers
22 views

I am having a problem with fetching product data in the Gutenberg block editor

const allProducts = useSelect((select) => { return select('core').getEntityRecords('postType', 'product', { per_page: -1, _embed: true, }); }, [...
0 votes
1 answer
2k views

add action save post type and update post meta woocommerce

I want update post meta in product woocommerce when I save o update the product. I write this function (and insert in functions.php) with save_post_NAME_CPT but don't work. add_action('...
1 vote
1 answer
816 views

Is it possible to store Json data in post_meta and manipulate

I just want to add json data type in post meta field as like in normal database. json data will be in the structure below, Post Name Meta Data 1.Sample title 1 ---> ...
0 votes
2 answers
1k views

Create action running on trashed_post hook to modify post_meta value

I have a custom post type that always do math operation to its post_meta and other custom post type post_meta. For example: post-type 1 = cpt_product_order post-type 1 post_meta = ...
1 vote
1 answer
2k views

How to create a meta_query to get all posts with a specific meta data?

Here are the args for my query : $args = array( 'post_type' => 'product', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' =>...
1 vote
1 answer
2k views

Update post meta without deleting the old entries

$old = get_post_meta($post_id, 'figure_sugsubject_repeatable_fields', true); $new = array(); $figuresugsubjectpositions = $_POST['figuresugsubjectposition']; $figuresugsubjectworkplaces = $_POST['...
0 votes
2 answers
2k 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. ...
0 votes
1 answer
823 views

wordpress simple post multi rating with post_meta and user_meta

I am trying to create a multi criteria post rating function with simple form and post_meta and user meta. The Goal when users submits their ratings 2 things should happen: 1.the ratings is stored ...
0 votes
1 answer
789 views

How do I delete element from a serialized array upon deletion of a post?

I want to delete an element (post id) from a serialized array associated with a specific meta_key. The following screenshot tells the whole story. What you're seeing are, post ids saved in a ...
0 votes
1 answer
989 views

I need query_posts() to order results first by a meta value and then by post ID

I've read all the WordPress docs that seem relevant, and I've read lots of posts here and on other sites to find an answer to this, but I still can't find a way to do this. I have a custom post type. ...
0 votes
1 answer
1k views

get_post_meta image width for lazy load

I'm trying to lazy load a page of images in Wordpress - I've tried the plugins but none of them seem to work(I only want to lazy load image on some pages.) So I'm now trying to do it with a plugin - ...
0 votes
1 answer
1k views

How to programatically create a WooCommerce downloadable product?

Is there a way to add, for example, an MP3 file to a WooCommerce product from PHP rather than from the dashboard panel? Looking in the database I see that downloadable_files seems to be a serialized ...
0 votes
0 answers
19 views

CPT meta values intermittently return empty

I have a parent CPT (Form) and a child CPT (Registration). Form A currently has around 3,000 child registration posts. Am showing them on a custom admin table, 20 posts per page. The table columns ...
6 votes
2 answers
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: ...
0 votes
1 answer
49 views

How do I access the current post object within a block theme template or pattern?

How should I be able to query things like specific metadata or any other thing from the post object? Apparently I don't have access to basic functions like get_the_ID() or similar functions inside ...
0 votes
1 answer
772 views

Where is get_post_meta value located?

I'm working on a wordpress website created quite long ago. In the header file I see the following code: <?php query_posts("page_id=63"); while ( have_posts() ) : the_post() ?> <?php echo ...
1 vote
1 answer
818 views

How to update the title of audio file through its attachment metadata

I am trying to programmatically update some metadata of audio file attached to a post. I have been able to update the artist and album properties of the audio file but title doesn't stick. I can go ...
8 votes
3 answers
9k views

Best way to programmatically remove a category/term from a post

I am working on a script to convert all posts in a given category to use a postmeta flag instead (testing of MySQL has shown me that on a site as large as mine this will lead to a meaningful decrease ...
0 votes
1 answer
39 views

How can i delete default title tag from wordpress?

I used this code remove_action('wp_head', '_wp_render_title_tag', 1); to remove default title tag from WordPress. This helped the WordPress theme till Twenty Twenty One. But from Twently Twenty Two. ...
1 vote
1 answer
1k views

Saving zero as meta value

I have a meta_key called "_ordre" and each time I create a new custom post, a new meta_value is set for that meta_key. The thing is, when I set the value of '_ordre' to 0, the meta_value is not saved ...
0 votes
1 answer
1k views

Media Attachment Custom Meta Fields not saving in Media Uploader when using jQuery UI Autocomplete

I am trying to write a plugin that adds a custom meta field to image attachments to give images a credit field. I use the 'attachment_fields_to_edit' and 'attachment_fields_to_save' filters. ...
0 votes
1 answer
2k views

Get meta information from post parent

So I am in a single page and I want to get some meta information from a parent page. This code is inside my footer.php: if (is_single()) { global $post; $parent = get_post_achestor ( $post-&...
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 ...
0 votes
1 answer
28 views

Wordpress post meta key and value lookup

Correct me if im wrong but is this right when searching for poet meta key a value in Wordpress ? $args = array( 'post_type' => 'clientorders', 'meta_query' => array( array( 'key' =&...

1
2 3 4 5
40