Forum Replies Created
-
In reply to: Can AJAX be enabled for bbPress?
Noted.
For the case I will need a forum software again.
Thanks.In reply to: Can AJAX be enabled for bbPress?Hi @mrentropy,
I stopped using bbpress (for other reasons) a long time ago and even my website,
so I cannot try out your solution at the moment.
Thanks for the feedback.
No, I could not solve the issue.In reply to: Can AJAX be enabled for bbPress?Oh and I forgot to mention that I did test it by deactivating plugins and changing theme. The issue persists, when the shortcode is used.
Is AJAX enabled for the buttons if the Subscribe and Favorite buttons are used within the Replies shortcode?In reply to: Can AJAX be enabled for bbPress?Hi again,
I added this code:
if ( function_exists( 'bbp_enqueue_script' ) && function_exists( 'bbp_get_version' ) ) { bbp_enqueue_script( 'bbpress-engagements', 'js/engagements.js', array( 'jquery' ), bbp_get_version(), true ); }
so now it looks like this:
add_shortcode( 'bbpresscomments', function() { $output = ''; $current_id = function_exists( 'vcex_get_the_ID' ) ? vcex_get_the_ID() : get_the_ID(); $topics = new WP_Query( array( 'post_type' => 'topic', 'posts_per_page' => -1, 'fields' => 'ids', ) ); if ( $topics->have_posts() ) { // enqueue scripts on this next line... if ( function_exists( 'bbp_enqueue_script' ) && function_exists( 'bbp_get_version' ) ) { bbp_enqueue_script( 'bbpress-engagements', 'js/engagements.js', array( 'jquery' ), bbp_get_version(), true ); } foreach( $topics->posts as $topic ) { if ( get_the_title( $topic ) == get_the_title( $current_id ) ) { $output .= do_shortcode( '[bbp-single-topic id="' . intval( $topic ) . '"]' ); } } } return $output; } );
because I can see that code that enables all functionality including AJAX, is only enqueued for bbPress pages:
And it’s not enabled for bbPress shortcodes.
Is this right?
Could you please tell me what is wrong with my code, and why cannot I enqueue the scripts that will enable AJAX for the shortcodes?
Instead of proper enqueuing, my code makes the buttons not work at all, when I click on them, nothing happens.
In reply to: Can AJAX be enabled for bbPress?The reason is hard for me to debug this issue is that I am using this code to output a bbpress topic under each post that has the same name as the current post title:
add_shortcode( 'bbpresscomments', function() { $output = ''; $current_id = function_exists( 'vcex_get_the_ID' ) ? vcex_get_the_ID() : get_the_ID(); $topics = new WP_Query( array( 'post_type' => 'topic', 'posts_per_page' => -1, 'fields' => 'ids', ) ); if ( $topics->have_posts() ) { foreach( $topics->posts as $topic ) { if ( get_the_title( $topic ) == get_the_title( $current_id ) ) { $output .= do_shortcode( '[bbp-single-topic id="' . intval( $topic ) . '"]' ); } } } return $output; } );
This code is theme specific, so testing with an other theme doesn’t make sense in this case.
I will open now a ticket to my theme developer, but if you can see anything in this code that would make AJAX not work, please let me know.Thanks.
In reply to: Can AJAX be enabled for bbPress?Thanks!
I don’t use hand-coded, inline tempolates. I am using Templatera of WPBakery, and I am happy with it as it gives me a graphical overview of the structure, and they are easy to re-make or replace.
In WPBakery, I have a javascript module, an html module, but there is no PHP module.
But there is a text module which does accept shortcodes.
What do you recommend in this scenario?Thank you!
Should I insert the code above in my functions.php as it is, and use [bbp-single-topic id='.$forum_id.'] in my template?
The fact that is not tested, can it break my site?The idea is that I just simply want to display a topic with the same title as the post, under each post, as a comments section. Because they are post type, so I can achieve more with them in WordPress, as with comments.
Hi Robin,
no, in my single post template.
Originally I inserted them separately in my posts, but that of course comes with the lock-in effect, that is, if I want to change the layout of all of my posts, then i will have to edit them one by one – and this is unfeasible.