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

delete value 0 in post meta [closed]

This question is off-topic because your is a simple PHP error, not related to WordPress. You are trying to check if a variable is empty using: if ( $meta != $empty ) { but this is not the right way, in fact this code compare the target variable $meta with another variable $empty that is … Read more

Categories post-meta Tags post-meta

Group posts by meta_key

This is the solution, according to the asker. He used the get() method of the WP_Query class to retrieve an array of values (colors), each stored with the meta key color. Because [color] => ‘Yellow’ may appear in the array more than once, he then filtered the array through the PHP function, array_unique() which will … Read more

Categories wp-query Tags mysql, post-meta, wp-query

Custom query with query_posts doesn’t show post without certain meta_key

Well, you can’t sort by field that isn’t there. You can modify query conditionally only in those categories which have that field and let default query work in rest. It would be something like: if( is_category(‘abs’) ) query_posts( array_merge( array(‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘field_order’, ‘order’ => ‘Desc’ ), $wp_query->query ) );

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

get_post_meta – get a single value

If every meta value has the key f_name $meta = get_post_meta($post->ID, “company_wp_box_g”, true); echo $meta[‘fname’]; If you’re not sure of the contents & want to search for the first one available $name = false; $meta = get_post_meta($post->ID, “company_wp_box_g”, false); foreach($meta as $array) { if(isset($array[‘f_name’])) { $name = $array[‘f_name’]; break; } } echo $name;

Categories post-meta Tags post-meta

post meta data clearing on autosave

Using save post action I check state: <?php add_action(‘save_post’ ,’my_save_postdata’); function my_save_postdata ( $post_id ) { if ( defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE ) { return $post_id; } // logic }

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

Use a function to update post meta based on other post meta

Here are two simple ways to do this: One is to use the the_content-filter to update the post “hotness”, or you can schedule an event that will run daily and update the “hotness” once a day. First approach: the_content-filter Turn you code in to a “callable” function: function update_hotness( $post_id, $echo = false ) { … Read more

Categories functions Tags functions, post-meta

How to Update post status using meta data in Custom post TYpe

If I’m understanding correctly, you want to use your own select form to update a post’s published status instead of the publish/unpublish buttons? Something like this would work for that: function save_my_data($post_id){ if($_POST[‘publish’] == ‘yes’ && get_post_status($post_id) != ‘publish’){ //whatever your post variable is remove_action(‘save_post’, ‘save_my_data’); //if you don’t unhook the function you’ll have an … Read more

Categories custom-post-types Tags custom-post-types, 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
Older posts
Newer posts
← Previous Page1 … Page181 Page182 Page183 … 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