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

Ordering posts by metadata

Try meta_value_num ‘meta_key’ => ‘metadata1’, ‘orderby’ => ‘meta_value_num’ Add these 2 parameters to $args. This does the sorting considering metadata1 as numeric

Categories plugin-development Tags custom-field, get-posts, plugin-development, post-meta

Generate an Email address from that of the Post Author

You can use get_the_author_meta function. You can learn more about it here: https://developer.wordpress.org/reference/functions/get_the_author_meta/ Usage in your case: <a href=”https://wordpress.stackexchange.com/questions/290522/mailto:<?php echo get_the_author_meta(“user_email’);?>?subject=<?php the_title(); ?>”>Apply</a>

Categories post-meta Tags author, email, post-meta

Views count with time limit per IP

A very basic solution would be to use the Transients API, an example… function setPostViews($postID) { $user_ip = $_SERVER[‘REMOTE_ADDR’]; //retrieve the current IP address of the visitor $key = $user_ip . ‘x’ . $postID; //combine post ID & IP to form unique key $value = array($user_ip, $postID); // store post ID & IP as separate … Read more

Categories post-meta Tags post-meta

Display all custom post type posts and order them by an optional meta_key

<?php // query posts $query_property = query_posts( array( ‘orderby’ => ‘date meta_value’ // orderby date AND meta value ) ); // First loop $query_feat = $query_string.’&meta_value=on&meta_key=property_featured’; // Offset for second loop $query_all = $query_string.’&offset=3&meta_key=property_featured’; // First loop if ( $query_feat->have_posts() : while ( $query_feat->have_posts() ) : # etc…. // do stuff endif; // Second loop … Read more

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

Single reusable value for post meta: Custom Taxonomy or Post Meta?

For mutually exclusive values use post meta. It is faster to read than assigned taxonomies too. It is possible to create your own interface: Set the parameter show_ui to false when you register the taxonomy. Register a meta box where you print out all existing taxons with radio boxes. Add a save action to assign … Read more

Categories custom-taxonomy Tags custom-taxonomy, post-meta

Create a Metabox that behaves Like a Taxonomy Box

i ended up building a plugin that enforces radio buttons for any taxonomy. http://wordpress.org/extend/plugins/radio-buttons-for-taxonomies/ for the project in question i will probably also save the taxonomy as meta. sucks that i need/want half the ability of taxonomy (knowing other available terms, etc), but need the sorting by meta.

Categories post-meta Tags post-meta

Querying posts with meta value that begins with a certain pattern

Querying posts with meta value that begins with a certain pattern

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

Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]

For anyone who may have a similar need, I solved this the following way (on authors.php): First I get the author ID: $author = get_user_by( ‘slug’, get_query_var( ‘author_name’ ) ); // ID is accessed this way: $author_id = $author->ID; I then created a custom query: $query = ” SELECT p.* FROM $wpdb->postmeta m JOIN $wpdb->posts … Read more

Categories custom-field Tags custom-field, post-meta, query-posts, wp-query

How can I display my custom metaboxes on a custom post template?

Looking at your code, it appears all meta keys are prefixed with _cmb_. Your start time key is text_datetime_timestamp, so combined with the prefix, you want to fetch: get_post_meta( get_the_ID(), ‘_cmb_text_datetime_timestamp’, true ); Note the third parameter, which will retrieve a single value if set to true, as it’s possible to save multiple values under … Read more

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

How to best delete orphan wp_postmeta

This snippet is good enough, use it with $wpdb. In this case I would use : <?php add_action( ‘before_delete_post’, ‘my_func’ ); function my_func( $postid ){ // We check if the global post type isn’t ours and just return global $post_type; if ( $post_type != ‘my_custom_post_type’ ) return; // My custom stuff for deleting my custom … Read more

Categories custom-post-types Tags custom-post-types, post-meta, wpdb
Older posts
Newer posts
← Previous Page1 … Page162 Page163 Page164 … 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