Support » Plugin: Pods - Custom Content Types and Fields » Meta Query + taxonomy relation field

  • Resolved saiyyed

    (@saiyyed)


    I am getting issue when retrieve data from pods field(taxonomy relation field) by using meta query. i want to get data by slug if i put 14 that is term_id then it working fine but when i tried to use slug i got no result if anyone have idea please help me.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jim True

    (@jimtrue)

    Please provide your code if you’d like us to help you troubleshoot

    Plugin Author Jim True

    (@jimtrue)

    YOu’re calling your code in the inappropriate way; you should be using a tax_query, not a meta query: https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

    you would be using ‘field’ instead of key,

    field (string) – Select taxonomy term by. Possible values are ‘term_id’, ‘name’, ‘slug’ or ‘term_taxonomy_id’. Default value is ‘term_id’.

    Also, if you’re using a relationship field to a taxonomy, that’s the inappropriate way to work with Taxonomies and WordPress. You should have your taxonomy associated to the post-types.

    saiyyed

    (@saiyyed)

    Thanx @jimtrue for reply. I want taxonomy as a dropdown so i am using relation field and i got field as a dropdown see “https://prnt.sc/nqrjpv“. Now i want to get selected term from that field. I tried using tax_query as you told me “https://prnt.sc/nqrjk3” if i select checkbox then i got result but not from dropdown . I want to get result from dropdown please suggest me any idea.

    • This reply was modified 1 year ago by saiyyed.
    Plugin Author Jim True

    (@jimtrue)

    If you want to change the display parameters of your Taxonomy, there are methods for that:

    https://docs.pods.io/code-snippets/change-taxonomy-input-to-single-select/

    You should never use a Taxonomy as a relationship field, because it won’t work in your queries properly.

    You need to switch to an associated taxonomy and a tax_query as above and it will work properly.

    Plugin Author Jim True

    (@jimtrue)

    Basically, by switching a taxonomy to a relationship field, you break all the inherent taxonomy abilities of that taxonomy. That’s what you don’t want to do; you just want to change how it’s displayed. That link above will give you the ability to change the way the taxonomy is hanled in the back-end UI, but still let it behave like a taxonomy.

    saiyyed

    (@saiyyed)

    Wow amazing thanq so much @jimtrue. that i got what i want and your taxonomy query is working fine and i have dropdown too “https://prnt.sc/nr8fad“.

    • This reply was modified 1 year ago by saiyyed.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Meta Query + taxonomy relation field’ is closed to new replies.