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

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

Showing Meta Data for Custom Post Types?

On a single custom post type (for example), you can see the post meta. However on your homepage archive loop, you cannot because the theme uses a different template for this. Check out Template Hierarchy. The “home” page in _s is governed by the “index.php” template. In which we see: get_template_part( ‘content’, get_post_format() ); Since … Read more

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

Can’t sort order of wp_query with 2 meta keys

As you can read in Codex about orderby and the WP_Query, you can use multiple orderby values as well: ‘orderby’ => ‘name meta_value’ simply by using a space in between. The available orderby values are listed in the Codex page. About your question: By default it should already work with your query. If it doesn’t, … Read more

Categories custom-post-types Tags custom-post-types, meta-query, post-meta, pre-get-posts, wp-query

Post meta checkbox becomes unchecked occasionally

The trouble is that save_post fires in lots of places other than the “edit post” screen – when it does, your code will think the checkbox is unchecked and overwrite your saved state. Add an additional hidden input to your meta box: <?php // Don’t global post, use the $post parameter already passed to the … Read more

Categories save-post Tags post-meta, save-post
Older posts
Newer posts
← Previous Page1 … Page177 Page178 Page179 … 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