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

How to sanitize select box values in post meta?

When accepting user data inputs, I think that data validation must be performed if possible, not only sanitization. For example, you could expect a number, a bool value, a text string (even when the input is a selectbox it can have a string value), etc. You can santize for that data types; then you can … Read more

Categories theme-development Tags post-meta, sanitization, security, theme-development

How to hide meta box values from custom fields list?

Just add an underscore before the metabox ID so the part of your code where you add a metabox looks something like this: $id = ‘_drama-description’; $title=”Description”; $callback = ‘drama_description_metabox_markup’; $screen = $post_type; $context=”normal”; $priority = ‘high’; $callback_args=”null”; add_meta_box($id, $title, $callback, $screen, $context, $priority, $callback_args); You also need to replace every occurance of drama-description to … Read more

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

Delete duplicated wp_postmeta record

It is quite complicates grouped request, so to avoid problems, consider to use Cleanup Duplicate Meta plugin. The reason why duplicate entries are occured is usage of add_post_meta(). Just use update_post_meta() (even to create meta, it works) – and you will have always one meta field with certain name per post.

Categories posts Tags post-meta, posts

When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?

When multiple meta values are used for same meta key, WordPress store the values in different database rows. So every array, is stored in one row. Initial Data Let’s assume you have an array like this: $family = [ ‘father’ => [ ‘John’, ‘Doe’, 40 ], ‘mother’ => [ ‘Jane’, ‘White’, 39 ], ‘child_1’ => … Read more

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

Getting attachments by meta value

I’ve spent hours of research and found the solution a few minutes after writing this question: $args = array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, <<– IMPORTANT ‘meta_query’ => array( array( ‘key’ => ‘medientyp’, ‘value’ => ‘Video’ ) ) ); $query = new WP_Query($args);

Categories wp-query Tags attachments, custom-field, meta-query, post-meta, wp-query

Meta compare with date (stored as string) not working

Introducing STR_TO_DATE MySQL has a STR_TO_DATE function that you could leverage for the scope. To use it you need to filter the WHERE clause of a WP_Query, probably using posts_where filter. That function allows to format a column value as a date by using a specific format. By default, WordPress uses the CAST MySQL function … Read more

Categories post-meta Tags meta-query, post-meta

Content hooks vs User hooks

It depends on what exact action you are using, and what the purpose of that action is. For the update actions, for example, there should always be hooks that are triggered before doing the change (so that you may change or prevent it), and hooks that are triggered after the change has been completed (so … Read more

Categories post-meta Tags actions, post-meta, user-meta

Can I count the number of users matching a value in a multiple value key?

If you are working with serialized data as your meta_value, that sucks, as Pieter suggested, it’s best not to. However if there is no way around the serialization problem then I wonder if a meta_query using a compare value of LIKE might help… Example: //psuedo serialized data… (e.g. value of meta_key = fruits_user_like) //a:4:{i:0;s:5:”apple”;i:1;s:6:”orange”;i:2;s:6:”banana”;i:3;s:31:”serialized_data_sucks_sometimes”;} $users … Read more

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

Export WordPress Posts and Meta Information in CSV format

What is the SQL query you are using? What are more details of the export and end format you need? The obvious things are 1) http://wordpress.org/extend/plugins/navayan-csv-export/ “Navayan CSV Export is a wordpress plugin to export all your table data in CSV (Comma Separate Value) format.” and 2), exporting with phpmyadmin – the database utility – … Read more

Categories posts Tags post-meta, posts, sql

update_post_meta not saving when value is zero

update_post_meta() calls update_metadata which begins with this line: if ( !$meta_type || !$meta_key ) return false; I wrote a simple test (with a lot of cut & paste) to see how string values of 0 are evaluated (instead of looking it up in the PHP manual): <?php $meta_key = (string) 0; if ( ! $meta_key … Read more

Categories post-meta Tags post-meta
Older posts
Newer posts
← Previous Page1 … Page192 Page193 Page194 … Page203 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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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