• We have a few client use cases where we are trying to create a Dynamic Related Posts list using the Post Custom Field Contains Current Post ID option. However the custom field is an ACF Post Object with multi-select enabled. This means multiple post IDs are stored in a serialized array instead of simply the one post ID. We’ve slight adjusted the code to account for this option. This works for WordPress 3.7 and above.

    Edit file: advanced-post-queries/queries/module.php
    around line 511
    Replace this:

    $meta_query[] = [
    'key' => $settings[ 'postid_parent' ],
    'compare' => '==',
    'value' => $post_id,
    ];

    with this:

    $meta_query[] = [
    'relation' => 'OR',
    [
    'key' => $settings['postid_parent'],
    'value' => $post_id,
    'compare' => '=',
    ],
    [
    'key' => $settings['postid_parent'],
    'value' => sprintf('s:[0-9]+:"%d";', $post_id),
    'compare' => 'REGEXP',
    ],
    ];

    So far it seems to work well.
    @shabti @dynamiapps can you verify and possibly add this to the core?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Shabti Kaplan

    (@shabti)

    You, my friend, are brilliant. I will for sure review it, test it and add it to the plugin if all goes well.

    Thread Starter contemplate

    (@contemplate)

    Well I can’t take all the credit! My friend ChatGPT helped. ??

    But thank you for considering this!

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