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 can I get values using key in Carbon Fields from Multiselect?

One of the Carbon Fields developers here. Thank you for your feedback! Currently, the Carbon Fields stores only the keys and they don’t have a built-in method to retrieve the selected values from the options array. You can pass a callable which returns an array with the options as an argument to the add_options method. … Read more

Categories post-meta Tags post-meta

Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta

Here’s an answer to question 1 that uses register_post_meta. It’s also the start of an answer to question 2 by use of the prepare_callback option in show_in_rest . add_action( ‘init’, ‘wpse_89033_register_custom_meta’ ); function wpse_89033_register_custom_meta() { $post_types = [ ‘post’, ‘page’, ‘attachment’, ]; foreach ( $post_types as $post_type ) { register_post_meta( $post_type, ‘_custom_key’, array( ‘type’ => … Read more

Categories custom-field Tags block-editor, custom-field, post-meta, rest-api

Explanation for remove_filter used in the below code [closed]

The remove_filter() is necessary to avoid the callback from being called recursively, which would result in a memory issue due to a never-ending function execution. And that recursion could happen because the callback is hooked to get_post_metadata which is invoked via the get_metadata() function which the callback calls. So you need to first “unhook”/unregister the … Read more

Categories filters Tags actions, filters, post-meta

Conditionally Query Custom Post Types by Post Meta for Blog Home Page?

Hi @webcodeslinger: Here’s what a basic MySQL query for loading News and Events would look like (this is greatly simplified from what WordPress actually does): SELECT * FROM wp_posts WHERE post_type IN (‘news’,’events’) What you want instead is something like this (there are more performant ways to do this in MySQL but they are more … Read more

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

Convert User ID’s to User Names in a single.php file

$thevoters_ids = get_post_meta( get_the_ID(), “thevoters”, true ); // get a comma separated list of ids $thevoters_ids = explode( ‘,’, $thevoters_ids ); // turn the list into an array foreach ( $thevoters_ids as $thevoter_id ) { // loop through the ids $thevoter = get_user_by( ‘id’, $thevoter_id ); // get the user object by id echo $thevoter->display_name; … Read more

Categories functions Tags functions, post-meta

Using date stored as custom field to filter posts displayed in admin

Second try: 😉 pre_get_posts runs AFTER parse_query(). parse_query() transforms ‘meta_key’ etc. into ‘meta_query’. get_posts() doesn’t seem to react on ‘meta_key’ etc. directly. So try adding $query->parse_query() after your $query->set() calls or use filter that runs before parse_query (edited, the parse_query() filter doesn’t work, either – it runs too late). Edit: to do the switch: function … Read more

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

Trigger “unsaved changes” dialog for custom post meta changes

The code indeed only looks at the TinyMCE editor or the title and content field if the editor is hidden: window.onbeforeunload = function(){ var mce = typeof(tinyMCE) != ‘undefined’ ? tinyMCE.activeEditor : false, title, content; if ( mce && !mce.isHidden() ) { if ( mce.isDirty() ) return autosaveL10n.saveAlert; } else { title = $(‘#post #title’).val(), … Read more

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

Metabox Data not being saved [closed]

If that is all of your code, you’re missing a save_post action to save the data. Refer to the code sample provided on add_meta_box. add_action( ‘save_post’, ‘save_my_meta_box_data’ ); function save_my_meta_box_data( $post_id ){ // make sure it’s not an autosave if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; // verify your nonce if ( !wp_verify_nonce( … Read more

Categories post-meta Tags metabox, post-meta

metabox upload file

Again. If you are using file upload, it is different than image upload. To get a FILE url, use: $(html).attr(‘href’); File upload: window.send_to_editor = function(html){ var file_url = $(html).attr(‘href’); // Do something with those variables tb_remove(); }; Image upload: window.send_to_editor = function(html){ var file_url = $(‘img’, html).attr(‘src’), classes = $(‘img’, html).attr(‘class’), id = classes.replace(/(.*?)wp-image-/, ”); … Read more

Categories metabox Tags metabox, post-meta

Get aggregate list of all custom fields for entire blog

The function below will store a distinct list of all custom fields for the list of posts/pages/custom posts that is passed to it in the keys of the array $customfields. The array values are the number of posts with the corresponding field. In the example, custom fields added by plugins are excluded ($value[0] != ‘_’;) … Read more

Categories custom-field Tags custom-field, post-meta
Older posts
Newer posts
← Previous Page1 … Page165 Page166 Page167 … 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