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

Creating a custom post type upon registration

There is the action hook user_register that is called immediately after a user is added to the database. The user id is passed to the hook as an argument. You can use wp_insert_post to insert a new post in that action. You just need to get the relevant info from the user and add it … Read more

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

Set Expiration Date of a Post from the Frontend with wp_insert_post

The post by itself is only data, it cannot perform such action as expiring itself. So you need some form of external control to act on it. You can use WP Cron (see wp_schedule_event() and related) to run periodic task that will query for posts by your custom field and perform wanted action on them … Read more

Categories theme-development Tags post-meta, posts, theme-development

Up/Down voting system for WordPress

A simple user meta row can handle that for you (the second issue), you can store the post id and the vote (up/down) in an array and that is just the same as post meta ex /** * update user vote per post * @param int $user_id * @param int $post_id * @param mixed $vote … Read more

Categories custom-field Tags custom-field, front-end, post-meta, sql

Unable to save datetime custom meta field using update_post_meta() function

it seems that you’re using that plugin in a wrong way. It’s not necessary hook to save_post because the plugin do it for you. Simply register your meta box and your fields. To retrieve the values check this

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

Why am I getting an infinite loop with have_posts?

Look at this answer: get custom post type by tag I believe you’d use $flagged_stores->the_post() inside while loop.

Categories post-meta Tags loop, post-meta, recursive

WordPress Admin Panel search posts with custom post meta values along with title

With this code you can search in post list in WordPress Admin Panel with custom post meta values along with title and other default fields. Please, add below code in functions.php file: if (!function_exists(‘extend_admin_search’)) { add_action(‘admin_init’, ‘extend_admin_search’); /** * hook the posts search if we’re on the admin page for our type */ function extend_admin_search() … Read more

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

Transients vs CRON +Custom Fields: Caching Data Per Post

I think I would write a wrapper function around custom fields, something like this: function get_post_transient( $post_ID, $meta_key, $update_function ) { $current_value = get_post_meta( $post_ID, $meta_key, true ); if ( is_array( $current_value ) && $current_value[‘expiration’] < date(‘U’) ) return $current_value[‘data’]; $new_value = call_user_function( $update_function, $post_ID ); update_post_meta( $post_ID, $meta_key, $new_value ); return $new_value[‘data’]; } and … Read more

Categories custom-field Tags cache, cron, custom-field, post-meta, transient

How Do I Use WP_Query to Run This Database Query as Search Result?

Well, perhaps the answer could not be found in the WP_Query class for what I was trying to accomplish. Below is the final code that I plugged in to my functions.php file. I ultimately ended up search the WP_Query Class found in the wp_includes/query.php file. What I discovered is that there are a number of … Read more

Categories custom-post-types Tags custom-post-types, post-meta, pre-get-posts, search, wp-query

Create meta boxes that don’t show in custom fields

All post meta is shown in the custom fields, unless it begins with an underscore. So to ‘remove’ post meta from the custom fields metabox, you simply have to give it a name, beginning with an underscore. You’ll then be responsible for saving/updating the post meta (adding your own metabox where necessary).

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

List posts under meta_value heading

You should use some of WordPress’s built in functions, there is even a new meta compare parameter. You can create, for example: $state = get_post_meta($post->ID, ‘meta_state’, true); //the meta value to compare $query = new WP_Query ( array( ‘meta_key’ => ‘project’, ‘meta_value’ => ‘$state’, ‘meta_compare’ => ‘<=’, ‘post_type’ => ‘projects’ ) ); //spit them out … Read more

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