我正在将 WPML 用于 wordpress 多语言。这是我用来获取特色房地产的代码:
<?php
$propMgr = new PropertiesManager();
$properties = $propMgr->getProperties('featured');
if(empty($properties)) {
return;
}
?>
但是,此代码每三次返回特色属性,即对于我使用的所有三种语言。选择英语等时,我该如何使其仅以英语为单位。
更新:
当我做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
)
)
正如你在这里看到的,相同的属性被重复了很多次
更新:
http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/
他们已经在他们的文档中进行了解释。但是,我们提取properties
它的方式无济于事