Plugin Author
scribu
(@scribu)
Are you sure get_queried_object_id()
is what you expect?
well.. tried $post->ID too.. I really cant think what it should be
global $bbp;
echo $bbp->current_reply_id;
this echoes id successfully but still that loop not works with $bbp->current_reply_id
Plugin Author
scribu
(@scribu)
So you’re doing:
$connected = $my_connection_type->get_connected( $bbp->current_reply_id );
Does p2p_list_posts( $connected );
work?
nope.. not working..
function related_urun_cevap() {
global $bbp;
global $my_connection_type;
// Find connected posts
$connected = $my_connection_type->get_connected( $bbp->current_reply_id );
// Display connected posts
if ( $connected->have_posts() ) :
echo '<h3>Related posts</h3>';
p2p_list_posts( $connected );
endif;
//echo $bbp->current_reply_id;
}
add_action( 'bbp_theme_after_reply_content', 'related_urun_cevap' );
Plugin Author
scribu
(@scribu)
The problem is that the first reply is actually a topic. So $bbp->current_reply_id
is null, so get_connected() returns false.
If you had error reporting turned on, you would have seen a fatal error when you try to call have_posts() on a non-existing object.
Long storry short, just check current_reply_id before doing anything else:
function related_urun_cevap() {
global $bbp, $my_connection_type;
// First reply is actually a topic
if ( !$bbp->current_reply_id )
return;
// Find connected posts
$connected = $my_connection_type->get_connected( $bbp->current_reply_id );
// Display connected posts
if ( $connected->have_posts() ) {
echo '<h3>Related posts</h3>';
p2p_list_posts( $connected );
}
}
add_action( 'bbp_theme_after_reply_content', 'related_urun_cevap' );
Thank you 🙂
Last question:
is there any way to remove p2p-tab-create-post panel?
i temporary added
.p2p-tab-create-post {
display: none !important;
}
which is ugly solution tbh..
Plugin Author
scribu
(@scribu)
With the development version (0.9.6-alpha), you can do this:
p2p_register_connection_type( array(
...
'can_create_post' => false
) );
thanks 🙂
if you have a showcase list of your plugin, you can add this site:
http://kremim.com/soru/bioderma-photoderm-akn-mat-spf-30-krem/
http://kremim.com/soru/lutfen-cvp-verirmisiniz/
etc..
Those are bbpress forum topics that an expert answering questions and linking related products.