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

wordpress sorting using array merge by price in ascending order but price with 0 must be show last

hope this will usefull to some one. <?php /* ADDED by for sorting ASCENDING order but call for price (ie price with 0) last */ function my_sort_custom( $orderby, $query ){ global $wpdb; $orderby = ” case when CAST(meta_value AS SIGNED) = ‘0’ then 1 else 0 end ,CAST(meta_value AS SIGNED) “; return $orderby; } add_filter(‘posts_orderby’,’my_sort_custom’,10,2); … Read more

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

WP-API : post_meta not updated… but have another entry

I’ve answered my question… when your not giving the id of the post meta … it’s creating another one … you give the id and it’s updating… –

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

How to add together (get the sum) a field from all author’s posts

First you have to declare the global $wpdb before using it. Also you need to include the table prefix when calling the table names. global $wpdb; $posts_table = $wpdb->prefix . “posts”; $posts_meta_table = $wpdb->prefix . “postmeta”; Next get an array of post ids by the author needed( make sure you have the id of desired … Read more

Categories PHP Tags count, php, post-meta

Make Custom Fields Public in JSON – API

Check out this post under the “Get Posts Meta Field Is Not Available By Default” heading: https://1fix.io/blog/2015/07/20/query-vars-wp-api/

Categories custom-field Tags custom-field, json, post-meta, rest-api

add_post_meta insert null value into Database

Try update_post_meta function without esc_attr <?php update_post_meta($post_id, ‘province’, $_POST[‘postProvince’], true); ?>

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

SQL query : Select a thumbnail for a media

$Featured_image = $wpdb->get_results(” SELECT p.* FROM net_5_postmeta AS pm INNER JOIN net_5_posts AS p ON pm.meta_value=p.ID WHERE pm.post_id = $da_id AND pm.meta_key = ‘_thumbnail_id’ ORDER BY p.post_date DESC LIMIT 15 “,’ARRAY_A’); A related solution, to query for posts WITHOUT providing a post ID (ordered by post date, and using the wp_ database prefix): SELECT p1.*, … Read more

Categories Database Tags database, gallery, mysql, post-meta, sql

why get_post_meta is returning 0?

Please try below code and check if ‘sound_s‘ key exists in the array or not $file_id = get_post_meta($post_id); echo “<pre>”; print_r( $file_id ); exit;

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

get all posts with certain meta data

I think you can do a left join : left join $wpdb->postmeta my_field_meta on (p.ID = my_field_meta.post_id and my_field_meta.meta_key = ‘subscribe’) Where “subscribe” it’s the name of your custom field. So your code could be: $dayswithposts = $wpdb->get_results(“SELECT DISTINCT DAYOFMONTH(p.post_date) FROM $wpdb->posts as p LEFT JOIN $wpdb->postmeta my_field_meta on (p.ID = my_field_meta.post_id and my_field_meta.meta_key = … Read more

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

WordPress MS wp-admin/includes/post.php error with shortcode generator

I did spot one problem in your case clause for radio buttons: In your <label> tag, you use $val, but I think you meant $option[‘id’]. I don’t see how it could be related to the foreach error you’re getting, but it won’t hurt to fix it. The odd thing is that the real error is … Read more

Categories multisite Tags errors, multisite, php, post-meta

get_post_meta of multiple posts?

why not add a filed to user meta once they have voted and just check to see if that specific user can vote? add to your add vote function this lines: global $current_user; get_currentuserinfo(); add_user_meta( $current_user->ID , ‘voted’, true ); now if a user votes it saves a usermeta filed. then you can create a … Read more

Categories post-meta Tags custom-field, post-meta
Older posts
Newer posts
← Previous Page1 … Page14 Page15 Page16 … 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