• Resolved morris373

    (@morris373)


    Hi
    Another of my nightmares as I have spent time trying to get this to work.

    I have a Baptism Pod and a Clergy Pod. I have a field called Related_Clergy in the Baptism Pod and a field in the Clergy Pod called Related_Baptism.

    They are hopefully set up right as a relation between each other. I would like to add all the Baptisms onto each of the Clergy’s pages.

    On the Clergy’s single template page, I have set the Pod up for Baptism and I need a Where clause to filter by each Clergy i.e. Robert Williams.

    I have used this code and can’t get it to work:

    $clergy_name = get_the_title();
    $pods = pods( 'baptism', get_the_id() );
    $params = [
        'limit' => 10,
        'orderby' => 'baptism_number ASC',
        'where' => 'clergies_name = "' . pods_sanitize( $clergy_name ) . '"',
        ];
        $pods->find( $params );

    All I keep getting is unknown column, no matter how I try nothing works.

    • related_clergy
    • related_clergy.post_title

    Please point me into the right direction.

    Morris

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

    (@keraweb)

    You @morris373

    Your where clause doesn’t make sense. You said you named your field related_clergy right? In that case you should compare to the meta value (related_clergy.meta_value). This value contains the ID, not the Title (get_the_ID).

    However, since it seems you are using bi-directional fields, why no just do the following:

    $related_baptism = pods()->field('related_baptism');
    It will return an array of the related Baptism Pods of the current Clergy object.

    Cheers, Jory

Viewing 1 replies (of 1 total)
  • The topic ‘Select Where condition from a relationship field’ is closed to new replies.