-
Notifications
You must be signed in to change notification settings - Fork 0
/
setthreewayrelationships.php
52 lines (34 loc) · 1.38 KB
/
setthreewayrelationships.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
require(dirname(__FILE__) . '/../wp-load.php');
require(dirname(__FILE__) . '/../wp-content/plugins/sitepress-multilingual-cms/sitepress.php');
function get_translated_term($term_id, $taxonomy, $language) {
$translated_term_id = icl_object_id($term_id, $taxonomy, true, $language);
$translated_term_object = get_term_by('id', $translated_term_id, $taxonomy);
return $translated_term_object->name;
}
function langcode_post_id($post_id){
global $wpdb;
$query = $wpdb->prepare('SELECT language_code FROM ' . $wpdb->prefix . 'icl_translations WHERE element_id="%d"', $post_id);
$query_exec = $wpdb->get_row($query);
return $query_exec->language_code;
}
///////////// LOOP THROUGH ALL POSTS OF A CERTAIN POST TYPE - WORKS ON BOTH LANGUAGES
$events = get_posts(array(
'post_type' => 'events'
, 'posts_per_page' => 1000000000
));
if ($events)
foreach($events as $event) {
$postid = $event->ID;
$postlang = langcode_post_id( $postid );
// $participantstosearch = array(
// ''
// );
////////// INSERT PARTICIPANTS RELATIONSHIP TO EVENTS
// $participant = array(
// '2135',
// '2129'
// );
// update_post_meta($postid , 'participants_names', serialize($participant) );
};
?>