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

Unset field from an array not working as expected

Unset field from an array not working as expected

Categories post-meta Tags array, post-meta

Display All Custom Post Fields and Values, Unless Empty

This can easily be done with default PHP functions. // Loop through all fields, grab the content and assign it to a new array foreach ( get_post_custom() as $custom ) $new_custom[] = array_shift( $custom ); // Get rid of empty fields $new_custom = array_filter( $new_custom );

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

MySQL Query To Select Post By Postmeta

If I understand the question you are trying to show both post on single.php something like this should work as a second loop. Put This INSIDE the first loop. Do this so you can get the current post ID $parent_id=the_ID(); // Second Loop $query = new WP_Query( array ( ‘post_type’ => ‘TYPE1’, ‘meta_key’ => $parent_id … Read more

Categories post-meta Tags mysql, post-meta, wpdb

replacing the_autor or make callback

There is no need to change the the_author() function itself. A simple conditional tag will do the trick. Example: <?php /*** on your functions.php file ***/ function ifRegistered() { if(is_user_logged_in()) { the_author(); } else { echo get_the_post_meta($post->ID, ‘your_post_meta_key’, true); // or anything else, of course } } /*** on the template you want to use … Read more

Categories post-meta Tags loop, post-meta

Generate multiple goo.gl shortlinks for qtranslate bilingual blog

So I’ve managed to solve this. The googl_shortlink function from above now looks like this: function googl_shortlink($url, $post_id = false) { global $post; if (!$post_id && $post) $post_id = $post->ID; elseif ($post_id) $post = get_post($post_id); // list all the active languages in an array $enabled_languages = get_option(‘qtranslate_enabled_languages’); if (is_404()) return; if ($post && $post->post_status != … Read more

Categories post-meta Tags multi-language, plugin-qtranslate, post-meta

running function during post save and adding variable to post meta

Yes, most definitely. Take this skeleton code below as a base for a function that would do what you want, and place it in your functions.php: function your_vimeo_meta_function ($post_id) { // some verifications first if ( $post_id == null || empty($_POST) ) return; if ( !isset( $_POST[‘post_type’] ) || $_POST[‘post_type’]!=’post’ ) return; if ( wp_is_post_revision( … Read more

Categories post-meta Tags post-meta

“update_post_meta” not working in “wp_insert_post_data” hook

Two issues with your code in current form: wp_insert_post_data hook runs before the actual insertion happens. In other words post might not not exist yet. Data in this hook does not contain post_id. More fitting hooks to use are those after post insertion is processed: do_action(‘save_post’, $post_ID, $post); do_action(‘wp_insert_post’, $post_ID, $post);

Categories post-meta Tags post-meta

WordPress front-end media (image) upload ERROR!

Yes, got the problem. A minute off-track, and it’s wrong! :p On line 80, 87, 93 and 99 in Pastebin Codes, the syntax of media_handle_upload() was wrong. It should be substituted from media_handle_upload($postid,’product_image_1′); to media_handle_upload(‘product_image_1’, $postid); Because the syntax of media_handle_upload() is: media_handle_upload( $file_id, $post_id, $post_data, $overrides ); The $post_id cannot be before $file_id.

Categories post-meta Tags post-meta, uploads

How to use update_post_meta inside wp_trash_post

The Core “trash post” links in the “Quick Edit” section on edit.php and in the “advanced” form in the “Publish” meta box work over GET not POST. Unless you have altered the form(s) somehow, there is no POST data. All you have is the post ID. To save data when a post is deleted, you … Read more

Categories post-meta Tags post-meta, trash

Set Checkbox as checked by default

You should use delete_post_meta( $post->ID, ‘show_links’ ); instead of delete_post_meta( $post->ID, ‘show_links’, 1 ); the last form is used to delete specific values when you have multiple values with the same key. Here you most probably already stored a value which is an empty string that you never deleted and that’s what you get when … Read more

Categories post-meta Tags post-meta
Older posts
Newer posts
← Previous Page1 … Page35 Page36 Page37 … Page51 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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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