Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. Post
  2. -- image
  3. -- Featured image
  4. -- body
  5.  
  6. echo '<pre>';
  7. print_r(get_post_custom($post_id));
  8. echo '</pre>';
  9.  
  10. function get_all_meta($type){
  11. global $wpdb;
  12. $result = $wpdb->get_results($wpdb->prepare(
  13. "SELECT post_id,meta_key,meta_value FROM wp_posts,wp_postmeta WHERE post_type = %s
  14. AND wp_posts.ID = wp_postmeta.post_id", $type
  15. ), ARRAY_A);
  16. return $result;
  17. }
  18.  
  19. function acf(){
  20. $options = array();
  21. $acf = get_all_meta('acf');
  22. foreach($acf as $key => $value){
  23. $options['post_type'][$value['post_id']]['post_id'] = $value['post_id'];
  24. $test = substr($value['meta_key'], 0, 6);
  25. if($test === 'field_'){
  26. $post_types = maybe_unserialize( $value['meta_value'] );
  27. $options['post_type'][$value['post_id']]['key'][] = $post_types['key'];
  28. $options['post_type'][$value['post_id']]['key'][] = $post_types['name'];
  29. $options['post_type'][$value['post_id']]['key'][] = $post_types['type'];
  30. }
  31. if($value['meta_key'] == 'rule'){
  32. $post_types = maybe_unserialize( $value['meta_value'] );
  33.  
  34. $options['post_type'][$value['post_id']]['post_types'] = $post_types['value'];
  35. }
  36. }
  37. return $options;
  38. }
  39.  
  40. foreach(acf() as $key => $value){
  41. update_post_meta(76, $value['type'], 'Steve');
  42. }
  43.  
  44. $result = $wpdb->get_results($wpdb->prepare(
  45. "SELECT ID,post_title,post_parent FROM wp_posts WHERE post_type = %s", $type
  46. ), ARRAY_A);
  47.  
  48. // pods each field for a post type create separate post type so again query to get the field post type result.
  49. $pods_field_post_type = array();
  50. foreach($result as $value){
  51. $pods_field_post_type = $wpdb->get_results($wpdb->prepare(
  52. "SELECT ID,post_title,post_name FROM wp_posts WHERE post_type = %s
  53. AND post_parent = %d
  54. ", '_pods_field',$value["ID"]
  55. ), ARRAY_A);
  56.  
  57. }
  58. $fields = array();
  59. foreach($pods_field_post_type as key => $value):
  60. $podsAPI = new PodsAPI();
  61. $pod = $podsAPI->load_pod( array( 'name' => '
  62. post' ));
  63. $fields[] = $pod['fields'][$value['post_name']]['type'];
  64. endforeach;
  65. }
  66. print_r($fields);
  67.  
  68. foreach($fields as $key => $value){
  69. update_post_meta(76, $value, 'Steve');
  70. }
  71.  
  72. $post_type_features = get_all_post_type_supports( 'post' );
  73.  
  74. print_r( $post_type_features );
  75. /* Array
  76. * (
  77. * [0] => author
  78. * [1] => editor
  79. * [2] => thumbnail
  80. * [3] => excerpt
  81. * [4] => trackbacks
  82. * [5] => custom-fields
  83. * [6] => comments
  84. * [7] => revisions
  85. * [8] => post-formats
  86. * [9] => title
  87. * )
  88. */
  89.  
  90. $post_type_object = get_post_type_object( 'post' );
  91.  
  92. print_r( $post_type_object->supports );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement