Forum Replies Created
-
AuthorPosts
-
February 18, 2019 at 3:58 AM in reply to: Trying to display all the possible connection to a post #13390
Vee Jay
ParticipantI can get it to work like this:
$connected_conf2pub = new WP_Query( array( 'relationship' => array( 'id' => 'conf2pub', 'to' => get_the_ID(), // You can pass object ID or full object ), 'nopaging' => true, ) ); while ( $connected_conf2pub->have_posts() ) : $connected_conf2pub->the_post(); echo 'Connected Conf: <a href="' . get_permalink($post->ID) . '"><p>' . get_the_title($post->ID) . '</p></a>'; endwhile; wp_reset_postdata(); $connected_post2pub = new WP_Query( array( 'relationship' => array( 'id' => 'post2pub', 'to' => get_the_ID(), // You can pass object ID or full object ), 'nopaging' => true, ) ); while ( $connected_post2pub->have_posts() ) : $connected_post2pub->the_post(); echo 'Connected Posts: <a href="' . get_permalink($post->ID) . '"><p>' . get_the_title($post->ID) . '</p></a>'; endwhile; wp_reset_postdata(); $connected_pub2press = new WP_Query( array( 'relationship' => array( 'id' => 'pub_and_press', 'from' => get_the_ID(), // You can pass object ID or full object ), 'nopaging' => true, ) ); while ( $connected_pub2press->have_posts() ) : $connected_pub2press->the_post(); echo 'Connected Press: <a href="' . get_permalink($post->ID) . '"><p>' . get_the_title($post->ID) . '</p></a>'; endwhile; wp_reset_postdata();But would like to be able to display all the connections as one for design purposes. I don't really need to identify what's what, I just want to display all connections in date order.
February 18, 2019 at 1:09 AM in reply to: Trying to display all the possible connection to a post #13389Vee Jay
ParticipantI think I understand what the problem is.
You are using this code to display in an archive page where all your posts are listed. But what about when you are inside a single post?
Would the code change? Here's what I have in both function.php and the single post: https://ghostbin.com/paste/ksgheFebruary 14, 2019 at 9:10 AM in reply to: Trying to display all the possible connection to a post #13316Vee Jay
ParticipantI tried this and it still doesn't work :
$my_query = new WP_Query( array( 'post_type' => array( 'post', 'page', 'conference', 'publication', 'press'), 'post_status' => array ('future', 'publish'), 'paged' => $paged, 'posts_per_page' => 24 ) ); MB_Relationships_API::each_connected( array( 'id' => 'conf2pub', 'from' => $my_query->posts, 'property' => 'connected_confs', ) ); MB_Relationships_API::each_connected( array( 'id' => 'post2pub', 'from' => $my_query->posts, 'property' => 'connected_posts', ) ); MB_Relationships_API::each_connected( array( 'id' => 'pub_and_press', 'from' => $my_query->posts, 'property' => 'connected_press_items', ) ); while ( $my_query->have_posts() ) : $my_query->the_post(); foreach ( $post->connected_confs as $post ) : setup_postdata( $post ); the_title(); endforeach; wp_reset_postdata(); foreach ( $post->connected_posts as $post ) : setup_postdata( $post ); the_title(); endforeach; wp_reset_postdata(); foreach ( $post->connected_press_items as $post ) : setup_postdata( $post ); the_title(); endforeach; wp_reset_postdata(); endwhile;I get a " Invalid argument supplied for foreach() in " error.
February 13, 2019 at 10:48 AM in reply to: Trying to display all the possible connection to a post #13286Vee Jay
ParticipantI even tried the following
$related = new WP_Query( array( 'relationship' => array( 'relation' => 'OR', array( 'id' => 'conf2pub', 'to' => get_the_ID(), ), array( 'id' => 'post2pub', 'to' => get_the_ID(), ), array( 'id' => 'pub_and_press', 'from' => get_the_ID(), ), ), 'nopaging' => true, )); while ( $related->have_posts() ) : $related->the_post(); the_title(); endwhile; wp_reset_postdata();Vee Jay
ParticipantI tried that but I get the same thing.
Vee Jay
ParticipantI have the same problem with the "reset" of the field.
I also get this error when enabling debug mode:
WordPress database error: [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 'WHERE
to=150 ANDtype='post2conf' ORDER BY order_to' at line 1]
SELECTfromFROM WHEREto=150 ANDtype='post2conf' ORDER BY order_to -
AuthorPosts