wordpress - using WPML with real estate theme -
i using wpml wordpress multilanguage. code using fetch featured real estate properties:
<?php $propmgr = new propertiesmanager(); $properties = $propmgr->getproperties('featured'); if(empty($properties)) { return; } ?>
but, code returning featured property each 3 times i.e. 3 languages using. how can create homecoming english language when english language language selected , on.
update:
when print_r($properties);
( [0] => property object ( [_data:property:private] => wp_post object ( [id] => 1128 [post_author] => 1 [post_date] => 2014-10-22 21:20:57 [post_date_gmt] => 2014-10-22 21:20:57 [post_content] => [post_title] => villa porto taverna [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => villa-porto-taverna [to_ping] => [pinged] => [post_modified] => 2014-10-22 21:36:22 [post_modified_gmt] => 2014-10-22 21:36:22 [post_content_filtered] => [post_parent] => 0 [guid] => [menu_order] => 0 [post_type] => properties [post_mime_type] => [comment_count] => 0 [filter] => raw ) [meta:property:private] => array ( ) [id:property:private] => 1128 ) [1] => property object ( [_data:property:private] => wp_post object ( [id] => 1105 [post_author] => 1 [post_date] => 2014-10-22 21:20:57 [post_date_gmt] => 2014-10-22 21:20:57 [post_content] => [post_title] => villa porto taverna [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => villa-porto-taverna [to_ping] => [pinged] => [post_modified] => 2014-10-22 21:50:20 [post_modified_gmt] => 2014-10-22 21:50:20 [post_content_filtered] => [post_parent] => 0 [guid] => [menu_order] => 0 [post_type] => properties [post_mime_type] => [comment_count] => 0 [filter] => raw ) [meta:property:private] => array ( ) [id:property:private] => 1105 ) [2] => property object ( [_data:property:private] => wp_post object ( [id] => 1127 [post_author] => 1 [post_date] => 2014-10-22 21:20:57 [post_date_gmt] => 2014-10-22 21:20:57 [post_content] => [post_title] => villa porto taverna [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => villa-porto-taverna [to_ping] => [pinged] => [post_modified] => 2014-10-22 21:29:33 [post_modified_gmt] => 2014-10-22 21:29:33 [post_content_filtered] => [post_parent] => 0 [guid] => [menu_order] => 0 [post_type] => properties [post_mime_type] => [comment_count] => 0 [filter] => raw ) [meta:property:private] => array ( ) [id:property:private] => 1127 ) [3] => property object ( [_data:property:private] => wp_post object ( [id] => 1056 [post_author] => 1 [post_date] => 2014-10-21 21:13:49 [post_date_gmt] => 2014-10-21 21:13:49 [post_content] => [post_title] => villa verena [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => villa-verena [to_ping] => [pinged] => [post_modified] => 2014-10-22 20:05:54 [post_modified_gmt] => 2014-10-22 20:05:54 [post_content_filtered] => [post_parent] => 0 [guid] => [menu_order] => 0 [post_type] => properties [post_mime_type] => [comment_count] => 0 [filter] => raw ) [meta:property:private] => array ( ) [id:property:private] => 1056 ) [4] => property object ( [_data:property:private] => wp_post object ( [id] => 1071 [post_author] => 1 [post_date] => 2014-10-21 21:13:49 [post_date_gmt] => 2014-10-21 21:13:49 [post_content] => [post_title] => villa verena [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => villa-verena [to_ping] => [pinged] => [post_modified] => 2014-10-22 21:45:04 [post_modified_gmt] => 2014-10-22 21:45:04 [post_content_filtered] => [post_parent] => 0 [guid] => [menu_order] => 0 [post_type] => properties [post_mime_type] => [comment_count] => 0 [filter] => raw ) [meta:property:private] => array ( ) [id:property:private] => 1071 ) [5] => property object ( [_data:property:private] => wp_post object ( [id] => 1072 [post_author] => 1 [post_date] => 2014-10-21 21:13:49 [post_date_gmt] => 2014-10-21 21:13:49 [post_content] => [post_title] => villa verena [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => villa-verena [to_ping] => [pinged] => [post_modified] => 2014-10-22 21:39:56 [post_modified_gmt] => 2014-10-22 21:39:56 [post_content_filtered] => [post_parent] => 0 [guid] => [menu_order] => 0 [post_type] => properties [post_mime_type] => [comment_count] => 0 [filter] => raw ) [meta:property:private] => array ( ) [id:property:private] => 1072 ) [6] => property object ( [_data:property:private] => wp_post object ( [id] => 1017 [post_author] => 1 [post_date] => 2014-10-21 09:45:36 [post_date_gmt] => 2014-10-21 09:45:36 [post_content] => [post_title] => villa bella [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => villa-bella [to_ping] => [pinged] => [post_modified] => 2014-10-21 15:02:10 [post_modified_gmt] => 2014-10-21 15:02:10 [post_content_filtered] => [post_parent] => 0 [guid] => [menu_order] => 0 [post_type] => properties [post_mime_type] => [comment_count] => 0 [filter] => raw ) [meta:property:private] => array ( ) [id:property:private] => 1017 ) [7] => property object ( [_data:property:private] => wp_post object ( [id] => 1048 [post_author] => 1 [post_date] => 2014-10-21 09:45:36 [post_date_gmt] => 2014-10-21 09:45:36 [post_content] => [post_title] => villa bella [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => villa-bella [to_ping] => [pinged] => [post_modified] => 2014-10-21 20:55:33 [post_modified_gmt] => 2014-10-21 20:55:33 [post_content_filtered] => [post_parent] => 0 [guid] => [menu_order] => 0 [post_type] => properties [post_mime_type] => [comment_count] => 0 [filter] => raw ) [meta:property:private] => array ( ) [id:property:private] => 1048 ) [8] => property object ( [_data:property:private] => wp_post object ( [id] => 1049 [post_author] => 1 [post_date] => 2014-10-21 09:45:36 [post_date_gmt] => 2014-10-21 09:45:36 [post_content] => [post_title] => villa bella [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => villa-bella [to_ping] => [pinged] => [post_modified] => 2014-10-21 20:58:50 [post_modified_gmt] => 2014-10-21 20:58:50 [post_content_filtered] => [post_parent] => 0 [guid] => [menu_order] => 0 [post_type] => properties [post_mime_type] => [comment_count] => 0 [filter] => raw ) [meta:property:private] => array ( ) [id:property:private] => 1049 ) [9] => property object ( [_data:property:private] => wp_post object ( [id] => 974 [post_author] => 1 [post_date] => 2014-10-20 14:29:56 [post_date_gmt] => 2014-10-20 14:29:56 [post_content] => [post_title] => villa golfo aranci [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => villa-golfo-aranci [to_ping] => [pinged] => [post_modified] => 2014-10-20 15:25:19 [post_modified_gmt] => 2014-10-20 15:25:19 [post_content_filtered] => [post_parent] => 0 [guid] => [menu_order] => 0 [post_type] => properties [post_mime_type] => [comment_count] => 0 [filter] => raw ) [meta:property:private] => array ( ) [id:property:private] => 974 ) )
as can see here, same property beingness repeated many times
update:
http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/
they have explained in documentation. but, way have extracted properties
wont help
you can utilize icl_object_id(post_id, 'post_type', icl_language_code)
post id each property in current language.
for illustration if have simple array this.
$properties = array(1128, 1105, 1127, 1056, 1071, 1072, 1017, 1048); // ids properties. $post_ids = array(); foreach($properties $property) { $property_id = icl_object_id($property, 'properties', icl_language_code); // id current language $post_ids[$property_id] = 1; // set $property key override same results } foreach($post_ids $post_id=>$something) { // , here can utilize post_id can utilize get_post() or want... }
wordpress wpml
No comments:
Post a Comment