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

Grouping related postmeta data via SQL query

If I understand your question correctly, this should work: function get_event_info($event_id = 0, $info = ” ) { global $wpdb; return $wpdb->get_col( $wpdb->prepare( “SELECT meta_value from $wpdb->postmeta WHERE meta_key = ‘%s’ AND post_id IN (SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = ‘event_id’ AND meta_value= %s )”, $info, $event_id ) ); } Use this like … Read more

Categories query Tags mysql, post-meta, query

Job of meta_key meta_value fields in database tables

Think of them as array key/value pairs (kinda). These tables are used to store additional data about particular posts, comments, or users. The meta_key is the name by which the meta_value is retrieved, plus you have associations with particular posts, comments, or users by means of IDs. As far as structure goes, that is about … Read more

Categories post-meta Tags meta-value, post-meta, user-meta

How do I sort a custom post type admin column using two meta keys?

Store the date time as a single key in the format yyyy-mm-dd hh:mm:ss.

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

Filter list by a unique meta value dilemma

With some trial and error and help from @vancoder , the problem had to do with intval. The only section needing to be modified was the posts_where function. Had to remove the following line: $propertytype_value_number = intval( $_GET[‘propertytype_value_restrict_articles’] ); And change: AND meta_value=$beds_value_number )”; to AND meta_value=””.$_GET[“propertytype_value_restrict_articles’].”‘ )”; I had to also modify the original … Read more

Categories filters Tags actions, filters, post-meta

Set attached to state

Attachments are attached to a parent post. So when you get an attachment object, look into $attachment->post_parent. If that is 0, the file is not attached. The parent post ID refers always to another post in the posts table, never to an user. To attach the file to a user, you could create a hidden … Read more

Categories plugins Tags attachments, plugins, post-meta, posts

Hide post meta data on a specific category

Posting the answer that was solved by OP in one of the comments. This way it’s easier to read it. Hopefully a moderator can mark the question as solved. .page-template-template-magazine-php .post-meta, .category-services .post-meta { display:none; }

Categories categories Tags categories, child-theme, css, customization, post-meta

Problem With Order Item Meta In Woocommerce

Figured it out where I had if ( ! empty( $cart_item[‘presc_data’] ) ) woocommerce_add_order_item_meta( $item_id, ‘Olho Direito’, $cart_item[‘presc_right_sphere’] ); I had to change to $data = $cart_item[‘presc_data’]; if ( ! empty( $cart_item[‘presc_data’] ) ) woocommerce_add_order_item_meta( $item_id, ‘Olho Direito’, $data[‘presc_right_sphere’] );

Categories post-meta Tags post-meta, woocommerce-offtopic

Displaying Metabox value (custom post type taxonomy)

Try this For single template global $post; echo get_post_meta( $post->ID , ‘sm_taxonomy’, true ); OR For archive template if ( have_posts() ) : while ( have_posts() ) : the_post(); echo get_post_meta( get_the_ID() , ‘sm_taxonomy’, true ); endif;

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

How to make orderby ‘meta_value_num’ OPTIONAL?

Short answer: You can’t. Not like that, anyway. You could, however, grab all of the results from your query, regardless of the presence of that custom field, and completely unsorted, and then sort them using the PHP function uksort http://us1.php.net/manual/en/function.uksort.php Something like: $args = array( ‘cat’ => 5, ‘numberposts’ => 8 ); $posts = get_posts($args); … Read more

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

How to sanitize post meta field value?

HTML in custom fields is, from my point of view, a weird use case of custom fields. Even more if the purpose of the used HTML is just look and feel (<strong> and <i> can be seen as just look and feel). It is really better if you use the HTML markup on the custom … Read more

Categories post-meta Tags post-meta, sanitization
Older posts
Newer posts
← Previous Page1 … Page165 Page166 Page167 … 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