• Resolved bhenselmann

    (@bhenselmann)


    Hi,
    I′m working on moving some custom post types and custom fields from older plugins to Pods.
    One post type is “local authoroty” which could be “kind” of “local community”, “district” or “state” – that I have defined in a custom field “kind” in this custom post type.
    Now I want assign the local authooties to his district (if it is a “local community”) and state (if it is a “local community” or a “district”).
    I did this by creating two custom fields “district” and “state” with field type “Relationship”, Related To “local authoroty”, Selection Type “Single Select”.
    To reduce the selection to relevant local authorities of kind “district” or “state” I thought I can put “_pods_kind=’district'” into the Custom WHERE field in “Additional Field Options” tab. But I get error messages like
    “Database Error; SQL: SELECT DISTINCT t.ID, t.post_title, t.post_parent, t.post_type FROM wp_49_posts AS t WHERE ( ( _pods_kind =\’district\’ ) AND ….; Response: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘\’district\’ ) AND ….
    Now I found in Pods documentation, that this Customized WHERE might be for Special Magic Tags.
    Do I need an other syntax in the Customized WHERE field or is there an other way to acchieve this?
    Thanks for help – and for this helpful plugin!
    Bernhard

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @bhenselmann

    I’m not 100% sure we support metadata in the customized where field. But your best shot would be to use the magic tag notation like so:

    field_name.meta_value (not _pods_field_name).

    Cheers, Jory

    Thread Starter bhenselmann

    (@bhenselmann)

    Thanks Jory for fast answering!
    Unfortunately it′s not working. I tried different combinations, but unfortunately, I only received error messages.
    Do I understand it right, that – if I have a field named “kind” which could have the value “district” – the input in field “Customized WHERE” could be something like

    kind.meta_value = district
    ?
    Is there an other way to show only some specified posts of the custom post type in the selection?
    Greetings, Bernhard

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @bhenselmann

    Well, I didn’t think it would work, if I remember correctly you cannot filter by meta value.
    I’ll take a closer look into this but if you want to filter the relationship results your best shot is to use our PHP hooks: pods_field_pick_data and pods_field_pick_data_ajax_items

    Cheers, Jory

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @bhenselmann

    I’ve found the issue and it’s related to a recent bugfix we did. This fix introduces a bug with slashed in the field settings.
    In your case kind.meta_value = 'district' should work fine but this gets saved as kind.meta_value = \'district\' which results in an SQL error.
    I’ll try to make a patch a.s.a.p.!

    Cheers, Jory

    Plugin Author Jory Hogeveen

    (@keraweb)

    Closing this topic in favor of GitHub.
    You can follow progress here: https://github.com/pods-framework/pods/issues/5909

    Cheers, Jory

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to use Customized WHERE’ is closed to new replies.