1

Specifically, I'm trying to get get the 'Layout Group' of a given ThemeREX Custom Layout (which as I understand is just a Custom Post Type), but am also interested in seeing what other properties are available for that post.

I tried

print_r(get_post_meta(get_post(1738, 'ARRAY_A', 'display'),"",true)); 

but all that was returned was the number 1.

I'm guessing the meta is not what I'm looking for. Is there a way to iterate through all the custom properties that are registered with that post's CPT?

2

2 Answers 2

1

To get all the post_meta for a post, use:

$postmeta = get_post_meta(1738); print_r($postmeta); 

...which will give you a nested array of values that you can explore.

Once you've worked out what you need, you can get the individual setting / property / meta with:

$mySetting = get_post_meta(1738, "my-post-meta-key", true); 

Take a look at the relevant entry on the WordPress Codex for a bit more detail.

2
  • I still get just the number 1 returned. I tried it with a few different custom post types as well as a standard page... same results. Commented Nov 13, 2019 at 9:40
  • What did your print_r() result in? Have you checked the database to make sure the value is not "1"? Commented Nov 13, 2019 at 9:47
0

Try:

print_r( get_post_type_object( ( get_post( 1738 ) )->post_type ) ); 

It should print an object of class WP_Post_Type.

1
  • From context I believe they’re asking about post meta, not post type arguments, which wouldn’t include anything like what they describe. Commented Nov 12, 2019 at 23:59

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.