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

Will a large postmeta table slow a site down?

“You should not write to the DB on front end requests” is the eleventh commandment. Your performance will deteriorate due to the writes locking down the table much more than the impact the size of the table will have. You should probably write such data in files instead of DB, or at least use a … Read more

Categories posts Tags post-meta, posts

Check if user already visited this post today

Note! This code was not tested! <?php function my_visitor_cookie($post_id) { if ( empty($post_id) ) { global $post; $post_id = $post->ID; } // get post meta $count = get_post_meta($post_id, ‘unique_post_visits’, true); // if there was no meta value if( empty($count) ) { $count = 0; } // check if cookie was already set (cookie name for … Read more

Categories PHP Tags cookies, php, post-meta

meta_query where value is equal to given value

You’re almost there — you just need to add the comparison to your meta query: $args = array( ‘post_type’ => ‘product’, ‘meta_query’ => array( array( ‘key’ => ‘artist’, ‘value’ => $artistID, ‘compare’ => ‘=’ ) ) ); https://codex.wordpress.org/Class_Reference/WP_Meta_Query Remember to filter $artistID before accepting it in your query!

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

What is the advantage of the wp_options design pattern?

The ability to store abstract key-value pairs without modifying the database structure is the reason. Without that, WordPress loses much of its flexibility. I can’t speak for others, but the single largest reason why I develop atop WordPress is its flexible nature. To quote one of your links above, Usually the reasoning behind doing what … Read more

Categories custom-field Tags custom-field, database, options, post-meta, wpdb

get_post_meta() unserialize issue – returns boolean(false)

I have managed to fix it at my own. I have used following code to update post meta update_post_meta($post_id, ‘tb_data’, base64_encode(serialize($new_value_array))); …and following code to get post meta $tb_meta = get_post_meta($post->ID, ‘tb_data’, true); $tb_meta_unserialized = unserialize(base64_decode($tb_meta)); I hope this will help someone.

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

How do I remove all the metaboxes for a custom post type?

If you want to hide all the metaboxes for all users, you can do that through the get_user_option_metaboxhidden_{cpt}, default_hidden_meta_boxes or the hidden_meta_boxes filter, according to the /wp-admin/includes/screen.php file. Here’s an example for the post post type: /** * Hide all metaboxes in the global $wp_meta_boxes */ add_filter( ‘hidden_meta_boxes’, function( $hidden, $screen, $use_defaults ) { global … Read more

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

How can merge two arrays values in one array and save in database

When you are saving the multidimensional array you can use this code: $product_img_path[$count][‘wpc_resize_thumb_img’] = $upload_dir[‘url’].”https://wordpress.stackexchange.com/”.$resize_img_name; $product_img_path[$count][‘wpc_resize_bid_img’] = $upload_dir[‘url’].”https://wordpress.stackexchange.com/”.$resize_big_img_name; update_post_meta($post->ID, ‘wpc_images’, $product_img_path); That way you can get multidimentional array like you want: Array ( [1] => Array ( [wpc_resize_thumb_img] => http://localhost/test/wp-content/uploads/2015/06/Wallpaper_55-212×159.jpg [wpc_resize_big_img] => http://localhost/test/wp-content/uploads/2015/06/Wallpaper_55-500×375.jpg ) [2] => Array ( [wpc_resize_thumb_img] => http://localhost/test/wp-content/uploads/2015/06/Wallpaper_51-212×141.jpg [wpc_resize_big_img] => http://localhost/test/wp-content/uploads/2015/06/Wallpaper_51-500×333.jpg ) … Read more

Categories PHP Tags array, php, post-meta

get registered metaboxes by post type or post ID

Wrong Assumptions @Rarst or @Dan-Cameron answers may work, but assume that when you are viewing a post type editing page, the metaboxes for the other post type are all registered. There are different case in which that won’t happen: If metaboxes are registered using “add_meta_boxes_{$post_type}” hook, instead of the more common, generic “add_meta_boxes” they won’t … Read more

Categories metabox Tags metabox, post-meta

How to update/insert custom field(post meta) data with wordpress REST API?

I just ran a test with your code and in my opinion, this is not working because you have an error in the get_callback function. First time it will try to get the subtitle( or the timing_of_experience) but it will trigger an error because it doesn’t exists in the first place and this error will … Read more

Categories post-meta Tags post-meta, wp-api

Custom Post Type with Input fields to seperate table on database.

You should avoid creating more tables. Just do it if you really have a good reason to. Note that wp_postmeta can store practically any kind of data, and simply using the get_post_meta function can do all the job in most cases. But if you must use another table, and taking it generally, then you’re looking … Read more

Categories custom-post-types Tags custom-post-types, database, google-maps, input, post-meta
Older posts
Newer posts
← Previous Page1 … Page192 Page193 Page194 … 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