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

bulk Update post_meta with default values

You can add a new bulk action for posts with this code : $postType = “post”; add_filter(“bulk_actions-edit-” . $postType, function ($actions) { $actions[“specialSave”] = “Special save”; return $actions; }, 20); add_filter(“handle_bulk_actions-edit-” . $postType, function ($sendback, $doaction, $post_ids) { if (“specialSave” !== $doaction) { return; } foreach ($post_ids as $idPost) { // action to do for … Read more

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

Maintaining two permalink structures

I think your approach is not the good one. If I understand well, What you want to do is keeping the old permalinks for the old posts and stick with them, while having the new permalinks only for the new posts. You should consider having the new permalink structure for all the posts (old and … Read more

Categories permalinks Tags permalinks, post-meta

Can I safely delete a record, manually, in the wp postmeta table?

It’s unclear what the postmeta actually does so it could effect your website in any number of ways.At best it will just clear the field / option and the user will need to re-enter it for that specific page.At worst it could change a pages layout or orphan a media file in your media library … Read more

Categories post-meta Tags post-meta

How to include template according to meta post value

Finally got a solution. I was not able to get meta key ie my_key value then I used: $post_id = get_the_ID(); $has_customization = get_post_meta($post_id, ‘my_key’, true);

Categories templates Tags include, post-meta, templates

get_post_meta doesn’t work

You got the wrong id for your get_post_meta(). As you define the input-name by the id of the field in your metabox, it has to be portfolio_description. <?php echo get_post_meta($post->ID, “portfolio_description”, true); ?> Should do the trick. If you are not sure which name of the post_meta you need to call, try inspecting the input … Read more

Categories metabox Tags metabox, post-meta

update_post_meta from data in multidimensional array created from a form

First off, there’s a problem with your array. Arrays can not have duplicate keys. So, only the first key will be saved. You need to change your form to something like this. <input name=”mainStageSatOrder[theband0][theid]” type=”hidden” class=”band-id” value=”” />”; <input name=”mainStageSatOrder[theband0][theorder]” type=”hidden” class=”band-order” value=”” />”; <input name=”mainStageSatOrder[theband1][theid]” type=”hidden” class=”band-id” value=”” />”; <input name=”mainStageSatOrder[theband1][theorder]” type=”hidden” class=”band-order” value=”” … Read more

Categories array Tags array, post-meta

How to solve slow WordPress site caused by attachment_metadata

Rick James and I have created the (free, GPL) Index WP MySQL for Speed plugin. It addresses some of the performance problems with wp_postmeta by adding database indexes suitable for that table’s use cases. I use it myself on a Woo site with several thousand products. (It works on users, terms, options, and comments too.) … Read more

Categories Database Tags database, mysql, optimization, performance, post-meta

Rest Api v2 orderby meta_key in custom post type

You can use this filter to change order : $type = “cptCode”; add_filter(“rest_” . $type . “_query”, function ($args, $query) { $args[“orderby”] = “meta_value”; $args[“meta_key”] = “my_meta_field”; return $args; }, 10, 2); You can also test $_GET to change the order conditionally.

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

Display info from custom fields in all images’ HTML

You can create a filter using the “wp_get_attachment_image_attributes” hook. Place this in your functions.php file. function filter_image_title($attr, $attachment = null){ //Find your $photographer with $attachment->ID $attr[‘title’] .= ‘ (‘ . __(‘Photographed by’, ‘foobar’) . ‘ ‘ . $photographer . ‘)’; return $attr; } add_filter(‘wp_get_attachment_image_attributes’, ‘filter_image_title’, 10, 2);

Categories custom-field Tags attachments, custom-field, hooks, images, post-meta

Edit meta data does’t work with custom sql

Try the following… global $wpdb; $wpdb->query( ” UPDATE {$wpdb->prefix}postmeta SET post_id = {$edit_id}, meta_key = ‘{$meta_key}’, meta_value=”{$meta_value}” WHERE post_id = {$edit_id} AND meta_key = ‘{$meta_key}’ ” ); //or using prepare $wpdb->query( $wpdb->prepare( ” UPDATE {$wpdb->prefix}postmeta SET post_id = %d, meta_key = %s, meta_value = %s WHERE post_id = %d AND meta_key = %s “, $edit_id, … Read more

Categories posts Tags post-meta, posts
Older posts
Newer posts
← Previous Page1 … Page178 Page179 Page180 … 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