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

Post Meta statement?

Use an if or switch statement to check the value of the meta, then echo out a different class name based on the value: <?php $type = get_post_meta($post[‘ID’], ‘Type’, true); switch ( $type ) { case ‘Yes’: $class=”type-yes”; break; case ‘No’: $class=”type-no”; break; default: $class=”type-na”; break; } ?> <span class=”widget_last <?php echo $class; ?>”><?php echo … Read more

Categories PHP Tags php, post-meta

Optimize WP Meta Query for large amount of post meta?

Ok, Ive found that ‘compare’ => ‘!=’ slows it down, but ‘compare’ => ‘<>’ does not. I guess both are the same, so I guess this question is solved.

Categories post-meta Tags meta-query, optimization, post-meta

Sort by postmeta on when searching

Problem was that I had a plugin installed that deals with the searches, it’s called Better Search. function query_1($query){ $query .= “,wp_postmeta.meta_value as total_saless “; return $query; } add_filter( ‘bsearch_posts_match_field’, ‘query_1′ ); function query_2($query){ $query .= “AND wp_postmeta.meta_key=’total_sales’ “; return $query; } add_filter( ‘bsearch_posts_where’, ‘query_2’ ); function query_3($query){ $query = ” CAST(total_saless AS INTEGER) > … Read more

Categories query Tags post-meta, query, search

show user based on user_meta

you can create conditionnal arguments like that : $user_args = [ ‘orderby’ => ‘display_name’, ‘order’ => ‘asc’, ‘meta_query’ => array( array( ‘key’ => ‘verifier_assign_country’, ‘value’ => $countryCode, ‘compare’ => ‘=’ ), ) ]; if (“” !== $univCode) { $user_args[“meta_query”][] = array( ‘key’ => ‘verifier_assign_univ’, ‘value’ => $univCode, ‘compare’ => ‘LIKE’ ); } $users = get_users($user_args);

Categories post-meta Tags post-meta, user-meta, users

Update Post metafield of specific categories

OK, so a little bit of guessing is involved in that answer, since you’ve posted only parts of your code, but… I assume that your code looks like that: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘post_category’ => array(14,16,19) ); $posts = get_posts($args); foreach ( $posts as $post ) { … Read more

Categories post-meta Tags post-meta

When working with a post, almost all wp_postmeta are deleted

When working with a post, almost all wp_postmeta are deleted

Categories PHP Tags custom-field, php, post-meta, posts, updates

How do I update a specific value within array in a products metadata?

It’s a little bit off-topic, but nevertheless… Let’s say you want to change first range_cost to 5.789 and third to 6.890 for product 148. Here’s the code: $product_attr = get_post_meta( 148 , ‘redq_day_ranges_cost’); $product_attr[0][0][‘range_cost’] = 5.789; $product_attr[0][2][‘range_cost’] = 6.890; update_post_meta(148, ‘redq_day_ranges_cost’, $product_attr);

Categories post-meta Tags post-meta

Move Entry Meta Above Title in Archives (Genesis + Brunch Pro)

Move Entry Meta Above Title in Archives (Genesis + Brunch Pro)

Categories post-meta Tags post-meta

Check value of post meta within IF statement

Check value of post meta within IF statement

Categories loop Tags loop, post-meta

Remove item from post_meta array via AJAX

Remove item from post_meta array via AJAX

Categories PHP Tags ajax, array, jquery, php, post-meta
Older posts
Newer posts
← Previous Page1 … Page49 Page50 Page51 … 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