Skip to content

Instantly share code, notes, and snippets.

@hasinhayder
Last active April 15, 2020 15:18
Show Gist options
  • Save hasinhayder/1035dae4403bf2a67f92abd2690fd427 to your computer and use it in GitHub Desktop.
Save hasinhayder/1035dae4403bf2a67f92abd2690fd427 to your computer and use it in GitHub Desktop.
posts using wpdb
<?php
global $wpdb;
$_posts = $wpdb->get_results("SELECT ID, post_title from {$wpdb->prefix}posts WHERE post_status='publish' and post_type='post'",ARRAY_A);
$p = [];
foreach($_posts as $_post){
$p[$_post['ID']] = $_post['post_title'];
}
//now pass this $p array to carbon field's set_option() function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment