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

Get only used meta_values

I am not sure if I get your question right, and thus don’t know if this answer goes into the right direction… Is this what you’re trying to achive? $apart_locations = $wpdb->get_col( “SELECT meta_value FROM $wpdb->postmeta AS wppm LEFT JOIN $wpdb->posts AS wpp ON wppm.post_id = wpp.ID WHERE wppm.meta_key = ‘postal_location’ AND wpp.post_status=”publish” ORDER BY … Read more

Categories custom-post-types Tags custom-post-types, get-posts, post-meta, publish

delete post meta by AJAX

Your problem is global $post. You have to understand that any ajax call, is a new http request, that has nothing to do with the page that send the ajax request. If you want to pass information from the page that send the request to the page that receive the request, you have to pass … Read more

Categories jQuery Tags ajax, jquery, metabox, post-meta

Combining wp_insert_post() and update_post_meta()

2020 Update: In case you landed here looking for a refresher on how to update the post’s meta, as I did, see the following edit: The post array argument in wp_insert_post() takes an inner array called meta_input, so you can create the post with proper meta in one database query. $page_id = wp_insert_post(array( ‘post_title’ => … Read more

Categories wp-insert-post Tags post-meta, wp-insert-post

Why does get_transient() always return string even if integer set?

Transients are stored as options in the wp_options table (in most cases). All option values are always converted to strings when stored. The table that holds them has the option_value column defined as longtext, and the option functions escape to string values when creating the SQL. Thus, bare integers will be converted to strings. Since … Read more

Categories post-meta Tags post-meta, transient

shortcode in a custom metabox

I noticed that your are using get_the_content(), but it will return unfiltered content. The shortcodes are generated via the the_content filter with priority 11. So if you want only the shortcodes generated, try: ‘content’ => do_shortcode( get_the_content() ) to filter it through the_content filter, try: ‘content’ => apply_filters( ‘the_content’, get_the_content() ) to simulate the_content() function, … Read more

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

Meta box losing its value when scheduled post is published

I have not tested this, but my guess is that $_POST is not set when the post is saved when wp_cron changes the status from “Scheduled” to “Published”, and so your value gets saved/reset to 0. Instead of using save_post you could hook to the several transition hooks that fit your needs. Or you could … Read more

Categories plugins Tags plugins, post-meta

Display get_post_meta if contains value

I actually managed to achieve what I needed to do in the end by using the below:- <?php if(get_post_meta($id, “h1_title_override”, true) !== ”) { ?> <h1><?php title_override_text(); ?></h1> <?php } else { ?> <h1><?php title_text(); ?></h1> <?php } ?> With the necessary functions in place of course…

Categories post-meta Tags post-meta

How to selected which tags to print, instead of printing the whole tag list?

By get_the_tags() you receive an array of tags attached to the current post. So you could do the following: $tags = get_the_tags(); $tag_ids_to_print = array( 1, 2, 3 ); //List of Tag IDs which you want to be printed $print_tags = array(); if( is_array( $tags ) ){ foreach( $tags as $tag ){ if( in_array( $tag->term_id, … Read more

Categories post-meta Tags post-meta, tags

Hide posts with meta key in WP_Query

Use compare with NOT EXISTS to get posts without that meta key. ‘meta_query’ => array( array( ‘key’ => ‘featured_post’, ‘compare’ => ‘NOT EXISTS’, ), )

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

Get post id within comments loop

Note that it might be easier to use get_comments() here, since it’s defined as: function get_comments( $args=”” ) { $query = new WP_Comment_Query; return $query->query( $args ); } If you need the comment url, within your foreach comment loop, you can use: $comment_url = esc_url( get_comment_link( $comment ) ); You can also get the post … Read more

Categories PHP Tags comments, loop, php, post-meta
Older posts
Newer posts
← Previous Page1 … Page116 Page117 Page118 … 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