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

How do you handle postmeta in admin area?

Actually is not true that on post-new.php global $post is not defined, WordPress create a post and save it in database as auto-draft using get_default_post_to_edit before output the page and so the metabox, so you can rely on global post object. However, I don’t like using global post object and to get the brand-new post … Read more

Categories admin Tags admin, post-meta

Notice: Undefined index: error and understanding wordpress

First thing i see that needs to be changed is your assigining unchecked values to your input fields. Try wrapping isset round the variable before echoing, this will stop errors if they are not assigned or empty. Second thing as you have passed a post id to get_post_custom() you dont need the second array. function … Read more

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

Display custom field meta outside loop, site wide

To display post meta value from a specific post in header, you can print it like this with specifying post ID instead of variable $post-ID. <?php echo get_post_meta( ‘1234’, ‘breaking’, true ); ?> get_post_meta accepts post id and if you only need to show post meta from one specific post then you can define post … Read more

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

echo image caption

Retrieve caption of image correct format is <?php $post_thumbnail_id = get_post_thumbnail_id( $post_id ); ?> <?php function wp_get_attachment( $attachment_id ) { $attachment = get_post( $attachment_id ); return array( ‘alt’ => get_post_meta( $attachment->ID, ‘_wp_attachment_image_alt’, true ), ‘caption’ => $attachment->post_excerpt, ‘description’ => $attachment->post_content, ‘href’ => get_permalink( $attachment->ID ), ‘src’ => $attachment->guid, ‘title’ => $attachment->post_title ); } $at= wp_get_attachment($post_thumbnail_id); … Read more

Categories post-meta Tags captions, images, post-meta, twitter-bootstrap

Long Polling: Stuck in while loop

PHP is not a multi tasking language, you should not try to use it as such. In other words, long polling is not something you should try to even attempt unless you use a language construct designed to support it. Specifically to your question, you probably fail because wordpress has the habit of caching in … Read more

Categories ajax Tags ajax, post-meta

Echo page title from page with custom meta datetime picker

This should output the title of the page with the most recent timestamp: $args = array( ‘post_type’ => array( ‘page’ ), ‘order’ => ‘DESC’, ‘orderby’ => ‘meta_value_num’, // Note was `meta_value` before ‘meta_key’ => ‘_cmb_test_datetime_timestamp’, ‘numberposts’ => 1, ); $posts = get_posts( $args ); if ( $posts ) echo $posts[0]->post_title; wp_reset_postdata(); To add conditions, use … Read more

Categories post-meta Tags post-meta

How to set YouTube video as featured image?

Well this is not exactly a WordPress problem / solution. First you have to either get the video id from the video_site_url post meta or save the YouTube video id in it’s own post meta field, maybe youtube_video_id. Next you can get the thumbnail using one of these url http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg Read this … Read more

Categories custom-post-types Tags custom-post-types, embed, post-meta, post-thumbnails, youtube

Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)

What else can I do to the query to do as little work as possible to eliminate “extra” posts in PHP that get queried because my query is too broad. The trouble is, meta queries are slow. Metadata is a simple key => value type database. Keys are indexed, and values are longtext. That’s it. … Read more

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

Get attachment by meta_key value

I think what you are after is get_post_meta() and not a custom query. REASONS: The results from custom fields are cached and extremely streamline when it cone to performance. You can read this answer I have done recently which will explain everything You are trying to get the custom field attached to a post only … Read more

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

How to check if user meta field is empty in conditional else statement

Does this do the trick? $consignment= get_post_meta($post->ID, ‘availability’, true); if ($consignment == ”) { // code to run if the above is empty, eg. echo “avaliable”; } else { // else the code, eg. echo $consignment; }

Categories custom-post-types Tags custom-field, custom-post-types, metabox, post-meta
Older posts
Newer posts
← Previous Page1 … Page143 Page144 Page145 … 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