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.
    – Daveh0
    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"?
    – WP Updoot
    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. Nov 12, 2019 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.