简体   繁体   中英

How to access wordpress custom post type Object

Please Help:

I am getting this Custom Post type Object within Wordpress. This is actually what print_r($this) returns.

How can I get the content of 'key', for example?

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 
                    )    
                )    
            ) 
        ) 
    )
)

Any help is highly appreciated it!

Run get_object_vars() on your $this to get the variables available to you. From there, you should be able to access the variable by its name through your instance like so:

$this->my_variable

Unless this is a dynamically-created variable, you should be able to simply look at the code, especially considering this is such a simple object. However, if you are ever in a pickle, I find this particularly helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM