Home Forums Backend Issues (wp-admin) Checking Post Type in Post Object field


Checking Post Type in Post Object field

  • Hi there!

    I’m editing a client website, and had a question regarding the Post Object field.

    My client has a slider on their homepage. In the back-end, I’m utilizing a Repeater field for each slide, with a Post Object field within that. As of now, the Post Object field only allows one post type. However, we’re going to be adding a second post type into the Post Object field.

    The issue I’m running into is that the second post type has different fields that I’d like to display within that slider, and I’m not sure what the proper code would be to target that new post type. Would I use a conditional statement? And if so, would that be something along the lines of “if( is_post_type(‘post-type’) )”?

    Thanks in advance for your help!

  • is_post_type() is not a WP function

    if (get_post_type($post_object->ID) == 'your-post-type') {
  • Thanks John! Very helpful.

    I knew is_post_type() wasn’t a function, but I thought writing something out like that was helpful in specifying what I was looking for.

    Again, thank you so much!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Checking Post Type in Post Object field’ is closed to new replies.