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

Sort by custom field that is an array?

At the stage of retrieving posts from database this is impossible (or at least impractical), since arrays are stored serialized by PHP in meta table and SQL won’t be able to process them on the fly effectively. This is easy enough to do for specific set of posts retrieved, just sort results in $mostsharedposts->posts before … Read more

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

WP_Meta_Query object with conditionals

I’m not sure if this is the whole problem but it seems you ‘posts_per_page’ is sitting inside your ‘meta_query’ while it should sit in the same level as ‘post_type’ and ‘category_name’…

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

How to add tags to post from frontend?

You can add this to form action: wp_set_post_tags( $post_ID, $tags, $append ) Function reference: wp_set_post_tags

Categories post-meta Tags post-meta, tags

Related query shows same image in loop

It”s probably because catch_that_image() is receiving the global $post_id the same with the_post_thumbnail() in your code you could pass the id of your current chapter catch_that_image($chapter->ID) or the_post_thumbnail( $chapter->ID ) this should solve your problem or you can try this code, it should work. <?php global $post; $current_post = get_the_ID(); $FeaturedArtist = get_post_meta($current_post, ‘FeaturedArtist’, true); … Read more

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

How can i get multi checkboxes value in metbox?

You can print the values of the array like this: $colors = get_post_meta($post->ID, $prefix . ‘colors’, true); foreach($colors as $color){ echo $color; }

Categories metabox Tags metabox, post-meta

How to echo value of a meta select box to the browser

I got your “broken” code in your answer to work and will explain why. First, here’s the edited code that wasn’t working for you: <?php //Get your post ID with a variable $this_post_id = get_the_ID(); //Removed get function from get_post_meta to make functionality clearer //I tend to avoid nesting functions that are grabbing post information … Read more

Categories post-meta Tags post-meta

Why is variable that get_post_meta stored in empty?

The variable that get_post_meta was stored in was empty because I wasn’t getting an id. I was trying to use this code on a category page, not a single event. Without an id it couldn’t identify the post_meta to use. So I corrected it with the following: $latest_cpt = get_posts(“post_type=event&numberposts=1”); $theidone =$latest_cpt[0]->ID; $this_post_id = $theidone; … Read more

Categories post-meta Tags post-meta

Editor meta box Showing but not saving

The problem was with this line: if(!$related_resources OR $related_resources == ”) return; I changed it to: if($related_resources == ”) return; And it started working properly. I hope others can make use of the code too. Thanks!

Categories metabox Tags metabox, post-meta, save-post

Get all metadata for a given custom post type

Your call should include the ID: get_post_meta($p->ID,”_location”,true); And what is $locations ? If an array, it should be $locations[] = If a string, it should be $locations .= If you only want unique locations, you could do this: $locations = array(); foreach($posts as $p){ $location = get_post_meta($p->ID,”_location”,true); if( ! in_array( $location, $locations) ) $locations[] = … Read more

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

Get YouTube video id from url in a custom field

An alternative would be to use WordPress’s build in auto embed, the following line in core is responsible for auto embed: add_filter( ‘the_content’, array(&$this, ‘autoembed’), 8 ); Which means: Whenever we are about to display content try to auto embed all url’s with a priority of 8. You could add a custom filter before this … Read more

Categories custom-field Tags custom-field, html5, post-meta, video-player, youtube
Older posts
Newer posts
← Previous Page1 … Page88 Page89 Page90 … 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