Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

post-meta

Multiple postmeta with same name for one post in wp_postmeta table

wp_insert_post runs whenever a post is updated, not just when it’s first saved. So your payment_meta() function is running every time a post is saved, and since you’re using add_post_meta() in that function, a new meta entry is created every time the post is saved. Instead of using add_post_meta() stick to just using update_post_meta() if … Read more

Categories Database Tags database, post-meta, wpdb

meta_post_meta return value 1

get_post_meta takes 3 params, not two: get_post_meta( int $post_id, string $key = ”, bool $single = false ) As you can see, the third param is false by default. It means, that if you don’t pass it, the function will return an array with all custom fields for that key. If you have only one meta field with key prep_time, you’ll get: Array( … Read more

Categories post-meta Tags post-meta

Make the checkbox meta field checked by default

Actually, your code is working, as long as $val == ‘on’. Did you try debugging by doing echo $val ? If it’s still not working, try hard refreshing (Ctrl + F5) your webpage, checkboxes tend to keep their state on normal refresh (F5). Also, please put your code directly on this forum, so the code … Read more

Categories plugins Tags custom-field, plugins, post-meta

WP_POSTMETA changes site crash

You shouldn’t change serialised PHP data structures directly. Serialised data contains the length of each value, and by changing a section of text, that length is no longer correct, and PHP runs into a fatal error and crashes. I don’t know what you are doing, but you should not modify serialised PHP strings manually.

Categories post-meta Tags post-meta, sql

need advice on how to do a lists using custom post types – taxonomy vs postmeta

Lists of items are already implemented in WP core. They’re called custom menus. They are stored as a custom post type + taxonomy. UPDATE: I had assumed that your list items would be other posts, but I’m getting the impression that you just need them to be strings. In this case, menus would be overkill … Read more

Categories custom-post-types Tags custom-post-types, custom-taxonomy, plugin-development, post-meta, theme-development

How can I get_post_meta() in the most efficient way?

You can use get_post_custom() which will return an array of all post meta in one single call to the database, that should save a few calls. And as for including the file over and over you could use get_template_part() to include a file once which will hold the entire loop (a good example can be … Read more

Categories custom-post-types Tags custom-post-types, post-meta

How to use wp_insert_post to update meta box?

It’s all going into the same table, you’re possibly not using the correct key name to insert it. The only thing that differentiates custom field keys and keys used for metaboxes is that metabox keys are typically prefixed with an underscore to hide them from the list that shows up in the custom fields section. … Read more

Categories wp-insert-post Tags post-meta, wp-insert-post

MySQL query to set wp_postmeta using term_taxonomy_id value

I think I know what you mean, and if that is the case it’s actually a straightforward operation. Firstly get all the object_ids from the term_relationship table. $results = $wpdb->get_results(“SELECT `object_id` FROM $wpdb->term_relationships WHERE `term_taxonomy_id` = 18”); And then run through each of those values and update_post_meta to 18. foreach ( $results as $result ) … Read more

Categories custom-field Tags custom-field, mysql, post-meta

Remove posts from query for events whose start date has passed

The date format is incorrect. I’m not sure how you have stored the date, but the format you’ve used in the query, date(“MM d yy”) outputs ‘MarMar 07 1212’. It shouldn’t really matter that the input is being done by jQuery datepicker: The input should be in a pre-specified format – so you can interpret … Read more

Categories query Tags get-posts, post-meta, query

mySQL query. ORDER BY meta_key

Zlatev meta_key is the name of the custom post type, and is a VARCHAR(255) meta_value is the value of the key, and is a longtext With your query you are not ordering by values, but by the name of the field. The query works for _thumbnail_id because you are using LEFT JOIN and the CPT … Read more

Categories query Tags mysql, order, post-meta, query
Older posts
Newer posts
← Previous Page1 … Page159 Page160 Page161 … Page204 Next →
+ More

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
Next Page »
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress