Support Forum » User Profile

Forum Replies Created

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • in reply to: Trying to display all the possible connection to a post #13390
    Vee JayVee Jay
    Participant

    I 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.

    in reply to: Trying to display all the possible connection to a post #13389
    Vee JayVee Jay
    Participant

    I 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/ksghe

    in reply to: Trying to display all the possible connection to a post #13316
    Vee JayVee Jay
    Participant

    I 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.

    in reply to: Trying to display all the possible connection to a post #13286
    Vee JayVee Jay
    Participant

    I 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();
    in reply to: Trying to create a relationship ends in SQL Error #12634
    Vee JayVee Jay
    Participant

    I tried that but I get the same thing.

    in reply to: Drag and drop order reset without consent #12573
    Vee JayVee Jay
    Participant

    I 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 AND type='post2conf' ORDER BY order_to' at line 1]
    SELECT from FROM WHERE to=150 AND type='post2conf' ORDER BY order_to

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