Support

Account

Home Forums Front-end Issues Display all posts with special treatment for relationships Reply To: Display all posts with special treatment for relationships

  • I’m going to try to improve and simplify my question to see if that helps anyone answer.

    1. I have a list of all the $values that impact a $strategy. I got that from the given strategy via repeater field with a post_object select. Cool!

    2. I’m trying to get a list of all the other $values. I want the $values not selected in that repeater field.

    I’m not sure how to get things that aren’t selected. Do I try to “subtract” things that are selected from the full list? Hopefully my comments below help explain.

                        <?php 
    // Query to get $values this $strategy does NOT impact
    // strategy_impact = repeater
    // impact_value_select = post_object
    // custom_value_description = text not used here, but elsewhere           
                        if ( get_field('strategy_impact') ): ?>
                        <div class="col-md-4">
                            <h4>No Impact</h4>
                        <?php while(has_sub_field('strategy_impact')) : ?>
                            <?php 
                            $impact_values = get_sub_field('impact_value_select');
                            $impact_values->post_title;
                            $impact_IDs = array($impact_values->ID);
                            $impact_IDs_comma = implode(",", $impact_IDs);
    //                      $custom_value_description = get_sub_field('custom_value_description');
    
                            // echo $impact_IDs_comma; 
                            // above results in a list of numbers 229 233 150 239 134 221 223 
                            // I thought it would give me commas like 229,233,150...
    
                            echo$impact_values->ID.',';
                            // above gives me 229, 233, 150, 239, 134, 221, 223,
                            // in order to get "a list of all UNselected non-post_object posts of this post_type" I thought I could use that as a 'post__not_in' parameter in a WP_Query, but it's not working 
    
                            ?>
    <?php /*                        $args = array (
                                'numberposts'   => '-1',
                                'orderby'       => 'title',
                                'order'         => 'ASC',
                                'post_type'     => 'values',
                                'post__not_in'  => $impact_IDs_comma
                                );
                            $all_values = new WP_Query( $args);
                            if ( $the_query->have_posts() ) : 
                            while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                            <h2><?php the_title(); ?></h2>
    <?php endwhile; ?><?php endif; ?>
    */?>
                            <?php endwhile; ?>
                         </div>
                        <?php endif; ?>