Mathematical operations on custom field values? (updated)

use here set type method: add_action(‘init’,’engineCreateRecurringSchedule’); add_action(‘engineRecurringCronJob’,’engineDaysToGoUpdate’); function engineDaysToGoUpdate(){ // Arguments to get published posts with ‘engine’ post type. $engineDaysToGoArgs = get_posts( array ( ‘post_status’ => ‘publish’ ‘posts_per_page’ => -1, ‘post_type’ => ‘engine’) ); // Calling the value of custom field. $engineDaysToGo = genesis_get_custom_field(‘wpcf-engine-days-to-go’); settype($engineDaysToGo, “integer”); // Subtracting 1 from the value. $updatedEngineDaysToGo = $engineDaysToGo–; … Read more

Get a different meta value with ajax when different elements are clicked

I figured it out myself thanks to this Q&A. The problem was with closures in loops. Can’t really explain what happens but it works for me. jQuery(document).ready(function($){ $.ajax({ url: ajaxurl, data: { ‘action’:’ajax_action’, ‘post_id’ : 18 }, success:function(data) { var hero = JSON.parse(data); function createCallback( i ){ return function(){ $(‘.changing’).html(hero[i][‘description’]); } } $(document).ready(function(){ for(var i … Read more