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

Add a meta to a post submited from a frontend form

Because the $post_id variable will return the ID of the new post, it was sufficient to change the line: $post_id = add_post_meta($post_id, ‘location2’, $data[‘postLocation2’]); to: add_post_meta($post_id, ‘location2’, $data[‘postLocation2’]);

Categories posts Tags post-meta, posts

get_post_meta with variable

You can use PHP’s range to iterate through letters. foreach( range(‘a’, ‘j’) as $letter ) { if( get_post_meta(get_the_ID(), ‘trmet_tour_status_’ . $letter, true) ){ echo get_post_meta(get_the_ID(), ‘trmet_tour_status_’ . $letter, true); } }

Categories PHP Tags php, post-meta

Edit is changing my custom’s post type parent id

Edit is changing my custom’s post type parent id

Categories custom-post-types Tags custom-post-types, gallery, post-editor, post-meta, wp-admin

Delete custom post type metadata without deleting the post in admin area

You have add_post_meta() and update_post_meta(), but you only need the latter: This may be used in place of add_post_meta() function. The first thing this function will do is make sure that $meta_key already exists on $post_id. If it does not, add_post_meta($post_id, $meta_key, $meta_value) is called instead and its result is returned. What you are doing … Read more

Categories custom-post-types Tags attachments, custom-field, custom-post-types, metabox, post-meta

Plugin Shortcode value in post

shortcode_parse_atts Accepts a string of shortcode attributes and returns an associative array of key/value pairs. // UNABLE TO TEST THIS // $value = get_post_meta(get_the_ID(), ‘some_value’, true); // $sc = $value [ ‘item_ticket_tailor’ ][ 0 ]; // TEST DATA – assuming the data is a string $sc=”[custom_event id=”3106″ ][custom_ticket id=”3220″ show_price=”true”]”; // pad some elements for … Read more

Categories shortcode Tags array, meta-value, post-meta, shortcode

Filter question list on substring of metavalue

Filter question list on substring of metavalue

Categories posts Tags filters, post-meta, posts

Delete custom meta

I found a function to get the Meta ID by Meta Key. This allowed me to correctly assign my $meta_ID variable, and now the delete ajax button works perfectly. No need to update the save function at all. function get_mid_by_key( $post_id, $meta_key ) { global $wpdb; $mid = $wpdb->get_var( $wpdb->prepare(“SELECT meta_id FROM $wpdb->postmeta WHERE post_id … Read more

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

Sort by meta key within same day

So here is a quick solution – with a bit of searching over SO and query analyzing : Keep the main query, but add a special filter for ordering. The filter (in function.php) : function my_posts_orderby( $orderby ) { $orderby = ‘DATE(wp_posts.post_date) DESC, wp_postmeta.meta_value DESC’; return $orderby; } Note the DATE() mysql function that takes … Read more

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

post_name is not stored until post is published… where should I store my slug until it goes live then?

When you use the graphical interface, post_name is stored in the wp_posts table even for draft posts as soon as you modify the default value. I tried your code (case 2) and I actually see the new entry in the database, with the correct post_name. Perhaps your check to post_name is not correct ?

Categories posts Tags permalinks, post-meta, posts, slug

wp_get_attachment_metadata()[‘image_meta’] fetch WP metadata or EXIF?

It is for EXIF data. But if that’s the code you’re using, it looks like you are trying to access array elements on a function call. Try $my_data = wp_get_attachment_metadata( get_post_thumbnail_id( get_the_ID() ) ); echo $my_data[‘image_meta’][‘credit’];

Categories post-thumbnails Tags post-meta, post-thumbnails
Older posts
Newer posts
← Previous Page1 … Page36 Page37 Page38 … 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