Support

Account

Home Forums General Issues Get all "values -> labels" for a Select field AND a specific post type

Helping

Get all "values -> labels" for a Select field AND a specific post type

  • Hi!

    I’ve created a “Select” field and now I need to get all the “values -> labels” for that field and for a specific post type (because the “Select” field is associated to many post types…).

    How can I make it?

    get_field_object() function has no option for post type…

    Thanks in advance!

  • Hi there!

    I will attempt to help… I have a question though…
    .. how do you want to display the values?

    For example.. you could append it to the content of a post, so then you would filter the_content() … and within your function you can write a conditional statement for a specific post type.

    In general, when you have access to the Post ID, you can determine the post type using the code below:

    
    if ( get_post_type( get_the_ID() ) == 'slug_post_type' ) {
        //if is true
    }
    

    Depending on the function you are using, you may have access to the Post Object, or the Post ID directly… so you would replace get_the_id() with however you get the Post ID in the given situation.

    Hope that helps! But please let me know if you need further clarification, and let me know the very specific goal and I can offer more direction if needed.

    Thanks for your inquiry,
    Keith

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

The topic ‘Get all "values -> labels" for a Select field AND a specific post type’ is closed to new replies.