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

Why is my get_post_meta always empty

get_post_meta as seen here is nothing more than a wrapper for get_metadata. Now when you say the meta you’re getting back, if its not null but rather an empty string, it means you’re hitting the end of get_metadata as seen here. With true defined as the third variable of your get_post_meta call, you should be … Read more

Categories PHP Tags php, post-meta, wp-mail

Update meta values with AJAX

Couple of things: 1: When you include the script after jquery, localise it using the wp_localize_script function: $nonce = wp_create_nonce(“vote_nonce”); $yourscript_info = array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’), ‘nonce’ => $nonce ); wp_localize_script( ‘yourscript’, ‘yourscript’, $yourscript_info ); $.ajax({ type: “POST”, url: yourscript.ajaxurl, data: { id: id, vote: vote, nonce: yourscript.nonce, action: “stn_voting” }, 2: Add some … Read more

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

How to sort by meta value?

Your meta value is a serialized array. What you’re asking it to get for you is all posts with a meta with the key ‘Notes’ and the value ‘price’. Your meta value is not ‘price’, though, it’s a:6:{s:5:”width”;s:3:”580″;s:6:”price”;s:3:”99″ The first thing you need to do to order by price is to start using a helpful … Read more

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

WP Query post meta value

Thanks to @Howdy_McGee. He gave me the hint to look after serialized meta queries. With this code I get the desired result. $args = array( ‘posts_per_page’ => -1, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_status’ => ‘publish’, ‘meta_query’ => array( array( ‘key’ => ‘enterprise_on_page’, ‘value’ => serialize(strval(‘trainees’)), ‘compare’ => ‘LIKE’, ), ), ); $enterprise_posts = … Read more

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

Making WordPress author follow button, need missing ingredient

I would advise you not to use the user meta. Although your problem is caused by: update_post_meta( $author_id, “_user_followed”, $followed_USERS ); // Add user ID to author meta update_post_meta( $author_id, “_author_follow_count”, ++$author_follow_count ); note that you called update_post_meta not update_user_meta, so somewhere, there’s a post whose ID is the same as the user ID of … Read more

Categories author Tags author, post-meta

Query for posts from any post type but only add instock products

You can check status instock only if meta key _stock_status exists. Something like: ‘meta_query’ => array( array( ‘key’ => ‘_stock_status’, ‘value’ => ‘instock’, ‘compare’ => ‘=’, ), ‘relation’ => ‘OR’, array( ‘key’ => ‘_stock_status’, ‘value’ => ”, ‘compare’ => ‘NOT EXISTS’ ), ) Note: Code is not tried or tested, so check for any syntax … Read more

Categories custom-post-types Tags custom-post-types, post-meta, woocommerce-offtopic, wp-query

get_post_meta fields don’t show up on posts page

Use it like this : <div id=”page” class=”hfeed site”> <?php do_action( ‘before’ ); ?> <?php $page_id = ( ‘page’ == get_option( ‘show_on_front’ ) ? get_option( ‘page_for_posts’ ) : get_the_ID ); $banner = get_post_meta( $page_id, ‘banner’, true ); if (is_front_page() || $banner == ”) { ?> <header id=”masthead” class=”site-header” role=”banner”> <?php } else { ?> <header … Read more

Categories custom-field Tags custom-field, homepage, id, options, post-meta

Having trouble with custom post type / meta box

Awesome – I got it working! Thanks everybody for your help and comments. Turns out the function had a problem because it was taking the $data in, but never returning it, because I had “return $data” in my if statement! Another problem was with the “WPSearch 2″ plugin”, it was breaking my “New Post” functionality … Read more

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

adding a URL to a post meta

Use another custom field with the URL and call it something like leetpress_website_url then change your code to this: <?php if ( get_post_meta( $post->ID, “leetpress_website”, true ) ){ echo ‘<div class=”pros”><p><strong>Movie Website: </strong><a href=”‘ . get_post_meta( $post->ID, “leetpress_website_url”, true ).'”>’ . get_post_meta( $post->ID, “leetpress_website”, true ) . ‘</a></p></div>’; } ?>

Categories post-meta Tags post-meta

How to get source of custom meta image?

Custom Meta Image? What’s that? Do you mean that, you are inserting an image into a custom field (post meta field) within your meta box? you are inserting an image as a post attachment or thumbnail? These are two very different things one of which is dealing with, add_post_meta the other, wp_insert_attachment The latter of … Read more

Categories custom-post-types Tags custom-field, custom-post-types, images, post-meta
Older posts
Newer posts
← Previous Page1 … Page175 Page176 Page177 … Page203 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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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