【发布时间】:2016-07-25 19:04:21
【问题描述】:
请帮忙:
我在 Wordpress 中获得了这个自定义帖子类型对象。这实际上是 print_r($this) 返回的内容。
例如如何获取'key'的内容?
Post_Types Object (
[post_types_definition:Post_Types:private] => Array (
[0] => Array (
[key] => solutions
[name] => Solutions
[taxonomies] => Array ( )
[categories] =>
[show_in_nav_menus] =>
[settings] => Array (
[0] => Array (
[title] => Solutions settings field
[description] => Solutions settings field
[type] => text
[properties] => Array (
[text-id] => solutions_settings_field_2
)
)
)
)
)
)
任何帮助都非常感谢!
【问题讨论】:
-
$this 的上下文是什么?
-
print_r($this) 输出上面列出的内容
-
这并不能告诉我任何事情。我们需要更多代码才能继续。看来 $this 实际上是指您要访问的对象??
-
没错。现在,如何获取“key”或“name”的内容?
-
哈哈,不客气。我会发布一个答案。如果您可以标记为答案并可能投票,我将不胜感激:)
标签: php wordpress object custom-post-type