Forum Replies Created

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • in reply to: Relation fields #9154
    levipe
    Participant

    Yes Steve,

    I understand the code has been altered.

    But, as I wrote, this creates issues with the filter in WooCommerce.
    A related field in a product cannot be filtered with WooCommerce anymore.

    That’s why I suggested the above modification to the code.

    C

    in reply to: Relation fields #9141
    levipe
    Participant

    So, this is what I added to the function relate() in class-piklist-form.php to establish the 2-way relationship

                  add_metadata($object['scope_to'], $from, $meta_key, $to);
                  // added CG 22/7/2018
                  add_metadata($object['scope_to'], $to, $meta_key, $from);

    But, it’d be better if Steve could add that to the core code

    in reply to: Relation fields #9138
    levipe
    Participant

    So,

    I got it working… half.

    The parts-code looks like this:

    piklist('field', array(
        'type' => 'checkbox',
        'label' => 'Regions',
        'choices' => piklist( get_posts( array(
            'suppress_filters' => false,
            'post_status' => publish,
            'numberposts' => -1,
            'post_type' => 'region' )),
            array( 'ID', 'post_title' )
        ),
        'relate' => array( 'scope' => 'post' ),
        'attributes' => array( 'class' => 'multiple' )
    ));

    and yes, the relationships are stored, like this:

    post_ID: 41
    meta_key: __relate_post
    meta_value: 1707

    post_ID is a post of post_type region and meta_value is a post holding a product.

    But, the symmetric relationship is not stored!

    post_ID: 1707
    meta_key: __relate_post
    meta_value: 41

    is not present in the DB.

    This hasn’t consequences on my layout (working with has_post and post_belongs as need be), but the queries in WooCommerce don’t work anymore because of the lacking symmetric relationship post. In this instance, I cannot query on ‘region’.

    in reply to: Relation fields #9034
    levipe
    Participant

    up

    in reply to: Filter in frontend #7919
    levipe
    Participant

    up

    in reply to: WPML #7779
    levipe
    Participant

    solved. Was a setting in WPML

    in reply to: Multipe post-relate #7720
    levipe
    Participant

    Well,

    found out what happened.
    Results get saved only if there is more than one custom post in the custom post type

    Example:
    if I’d have only one grape (eg Pinot Noir) in the grape post type, then the relation won’t save.
    If I have more than one, then the save is performed.

    I guess this might be one for the bug list

    Charles

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