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

update_post_meta not working in foreach

Doing something like this would help make sure the theme object has been instantiated properly… global $theme_options; if ( (!isset($theme_options) || (!is_object($theme_options)) ) { $theme_options = new My_Theme_Options_Class(); }

Categories save-post Tags post-meta, save-post

Saving Post Data in Another Database

This is possible, but you’re going to have to do a lot of custom work to get what you want. If you want all of your postmeta to come from and go to a separate database, you can use these filters: get_{$meta_type}_metadata – This filter is documented in wp-includes/meta.php. Returning a non-null value from this … Read more

Categories posts Tags advanced-custom-fields, custom-field, database, post-meta, posts

Print specific values stored in a post meta array

function get_value( $order, $parameters ) { $order_id = Compat\Order::get_id( $order ); global $wpdb; $ref_multibanco = get_post_meta($order_id,’_stripe_multibanco’, true); // select array $text_print=”Ent: “.$ref_multibanco[“entity”].'<br>Ref: ‘.$ref_multibanco[“reference”].'<br>Value: ‘.$ref_multibanco[“amount”]; return $text_print; }

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

Updating post meta for checkbox

Ok, so probably the meta data is saved correctly, now we are going to retrieve it. I’m not sure where and how you’re adding this code, it looks like a metabox? The checkboxes aren’t magicly getting checked, you need to add some logic to it. First we need to have a closer look how you … Read more

Categories posts Tags metabox, post-meta, posts

update_post_meta in loop changing ALL values

Look a this code: if( isset( $_POST [ ‘add_like’ ] ) ){ $update = $like_value + ‘1’; update_post_meta($post_id, ‘_like_value’, $update, $like_value); } Because you’re using it in a loop, it gets output multiple times on a page with a different value for $post_id each time. So essentially you have this: if( isset( $_POST [ ‘add_like’ … Read more

Categories post-meta Tags post-meta

change order of images attached to post

Answer Version 2 I apologize for the confusion. Here’s how you can use the usort() function to sort the images (in the div#pic-con on the front-end): <div id=”pic-con”> <?php if (!empty($vid_pix)) { usort( $vid_pix, function( $a, $b ){ $aPor = (int) get_post_meta( $a, ‘photo_order’, true ); $bPor = (int) get_post_meta( $b, ‘photo_order’, true ); if … Read more

Categories custom-field Tags array, custom-field, meta-query, post-meta, sort

Frontend form with multiple posts

What was happening was, the global variable $post wasn’t ending up on the POST page – so in the conditional below where the form was being processes, if ( ‘POST’ == $_SERVER[‘REQUEST_METHOD’] && ! empty($_POST[‘post_id’]) && ! empty($_POST[‘post_title’]) && isset($_POST[‘postcontent’]) ) { header(‘Location: /’); $post_id = $post->ID; $post = array( ‘ID’ => esc_sql($post_id), ‘post_content’ => … Read more

Categories query-posts Tags forms, post-meta, query-posts, wp-update-post

Update meta_value in wp_postmeta using API

I can’t really recreate the error. Are you sure the script is properly loaded? function get_post_details ($params) { return rest_ensure_response( ‘Hello World, this is the WordPress REST API’ ); } // Register the rest route here. add_action( ‘rest_api_init’, function () { register_rest_route( ‘post_info’, ‘post’,array( ‘methods’ => ‘GET’, ‘callback’ => ‘get_post_details’ )); }); This gave me … Read more

Categories rest-api Tags post-meta, rest-api

Display post number by category

Add this code to functions.php. It should add meta value to posts from given category. You can use hardcoded category slug/ID, but maybe it would be better to store it in options table and allow to change from dashboard. Change “ID”https://wordpress.stackexchange.com/”category_slug” to your own. /** * @param int $post_ID Post ID. * @param WP_Post $post_after … Read more

Categories posts Tags categories, database, post-meta, posts

How to store multiple custom meta box

I think it has nothing to do with wordpress. Shouldn’t this question be on stackoverflow? HTML: name=”quest_title[]” name=”quest_desc[]” PHP: foreach($_POST[‘quest_title’] as $key => $title) { $desc = $_POST[‘quest_desc’][$key]; //Here do whathever you want with this $title and $desc. } Solution: use empty brackets at the END of the name tag.

Categories PHP Tags custom-field, metabox, php, post-meta
Older posts
Newer posts
← Previous Page1 … Page97 Page98 Page99 … 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