Getting object ID

Support MB Term Meta Getting object ID

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38910
    YasmineYasmine
    Participant

    Hi,
    I have been trying to follow the documentation:

    $term_id = get_queried_object_id();
    $value = rwmb_meta( $my_custom_field_id, ['object_type' => 'term'], $term_id );

    to then query $value - so I can see if one term ID was selected on a post.

    I also tried $was_interview = get_post_meta( $post->ID, 'summary-made', true );

    But I cannot get it working!! Where am I going wrong? Is the term ID the slug of the taxonomy or the number? And do I need to add something else to get_queried_object_id() ?

    #38932
    PeterPeter
    Moderator

    Hello Yasmine,

    Can you please let me know the full scenario in this case? If you use this code

    $term_id = get_queried_object_id();
    $value = rwmb_meta( $my_custom_field_id, ['object_type' => 'term'], $term_id );

    It will work on the archive term page and get the term meta. But you also refer to this code

    $was_interview = get_post_meta( $post->ID, 'summary-made', true );

    which only works on the post page or in the WP Query loop.

    #38940
    YasmineYasmine
    Participant

    Hi Peter,

    I am just trying to query a term from a post. And so dependent on if a taxonomy term was selected to do X
    So I guess its your last snippet - thank you!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.