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

Detect meta value changes when post is updated (post_updated)

Like @SamuelElh comment this is how I solved it: add_action(‘updated_post_meta’, ‘check_meta_change’, 0, 4); function check_meta_change($meta_id, $post_id, $meta_key, $meta_value) { if( ‘<ENTER YOUR META KEY>’ == $meta_key ) { // do stuff } }

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

Manipulating post meta in the customizer

Please see the Customize Posts plugin. It has a WP_Customize_Post_Setting and WP_Customize_Postmeta_Setting for representing posts and postmeta in the customizer, respectively.

Categories customization Tags customization, post-meta, save-post, theme-customizer

Get updated meta data after save_post hook

Apparently in order to get the meta value right after saving the post, you have to either get the $_REQUEST[‘my_meta_value’] directly, or, if you need to update the database right away, you have to use update_post_meta() in your save_post action.

Categories custom-field Tags custom-field, hooks, post-meta, save-post

the_post_thumbnail() based on the Post ID

I got the solution so self-answering the question for future users/visitors. Hope it will help someone. I think this won’t be able to generate results based on the Post ID → the_post_thumbnail( ‘large’); However, this should work → <?php echo get_the_post_thumbnail($fpid, ‘large’); ?> (Above is succesfully tested) Other possibilities → <?php echo get_the_post_thumbnail($fpid, ‘thumbnail’); ?> … Read more

Categories PHP Tags functions, homepage, php, post-meta, single

Is it possible to store arrays in a custom field?

Yes you can, either by code: $demo = array(‘value1′,’value2′,’value3′); update_post_meta($post_id,’meta_key’,$demo); Or simply using the custom fields UI, add ass many values as you want one at a time and make sure they all have the same meta_key.

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

passing argument to get_template_part() or a better way to code

Why don’t you use a simple function with an argument to achieve that, the code is something like this: function wpse63585_event_list( $fresh = true ) { echo ‘<ul class=”event-items”>’; $yesterday = time() – 24*60*60; $compare = $fresh ? ‘>’ : ‘<‘; $args = array( ‘post_type’ => ‘wr_event’, ‘posts_per_page’ => -1, // show all posts ‘meta_key’ … Read more

Categories custom-field Tags custom-field, get-template-part, include, post-meta, templates

Use custom posts as taxonomy term meta replacement?

You can add taxonomy metadata, similar to add_post_meta and some examples of doing so include, Tutorial Walk-Through http://en.bainternet.info/2011/custom-taxonomies-extra-fields Taxonomy Metadata Class (improved version of above) http://en.bainternet.info/2012/wordpress-taxonomies-extra-fields-the-easy-way I have personally used this class myself which was also authored from a reputable member and moderator here at WPSE -> Bainternet, it did what it said on the … Read more

Categories custom-taxonomy Tags custom-taxonomy, post-meta

Get all posts from custom post type and insert in select input as metabox

(0. Retrieve the meta value with get_post_custom (in order to highlight the selected value in the select input).) Query posts with get_posts( array( ‘post_type’ => ‘services’, ‘post_status’ => ‘publish’ ) ) Loop through the results with foreach and build your select input. Hook into save_post (add_action(‘save_post’, ‘my_save_meta’) to store the selected value (with update_post_meta).

Categories custom-post-types Tags custom-post-types, input, metabox, post-meta, select

How can I display image metadata?

Because the credit data is saved in the attachment’s post meta, not the main post: $credit = get_post_meta( $post->ID /* Wrong ID! */, ‘credit’, true ); Instead you need to catch the ID of the inserted image: function attach_image_credit( $images ) { $return = $images[0]; // Get the image ID from the unique class added … Read more

Categories filters Tags attachments, filters, post-meta, the-content

Add options to featured image

You got it quite right, but with a few minor problems. First, please use a uniqe prefix for your functions and values – opacity or meta_save are quite generic and could be used by other authors. Second, the part where you get the meta opacity was missing, I added it for you – just retrieve … Read more

Categories functions Tags custom-field, functions, post-meta, post-thumbnails
Older posts
Newer posts
← Previous Page1 … Page185 Page186 Page187 … 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