dmmearns
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [WP Job Manager] Updating Address Schema Without Manual Address ChnagesThanks for the lead @bindlegirl !
This is a bit hacky and maybe I don’t need to change the address (but that’s what manually), however, it appears to do the trick:-
function get_all_job_listings(){ $args = array( 'post_type' => 'job_listing', //The default is 'post', which //excludes 'job_listing' posts. //To get all post types use //get_post_types('', 'names') 'post_status' => get_post_stati(), //All post statuses. 'nopaging' => true, 'numberposts' => -1 //No limit to the number of posts. //Default is only 5 :-O ); return get_posts($args); } function toggle_period_at_end_of_job_location(){ $posts_array = get_all_job_listings(); $job_location_meta_key = '_job_location'; foreach($posts_array as $post_array){ $pid = $post_array->ID; $job_location = get_post_meta($pid)[$job_location_meta_key][0]; $job_location = (substr($job_location, -1)==='.') ? substr_replace($job_location, '', -1) : $job_location.'.'; update_post_meta($pid, $job_location_meta_key, $job_location); } }- This reply was modified 4 years, 5 months ago by dmmearns.
Viewing 1 replies (of 1 total)