Skip to:
Content
Pages
Categories
Search
Top
Bottom

Placing activity loop in a new page using shortcode


  • cheekeat
    Participant

    @cheekeat

    Hi!

    I am trying to create a shortcode to place the activity loop in a new page, so I can customize and highlight some activities. To start, I inserted the standard loop inside a shortcode function (code as below). But the standard loop failed to show. Just to ensure that my shortcode is ok, I just inserted a “testing 123” text to check.

    FYI, I am using BuddyX theme (WordPress version 5.8.3). I test the code below in functions.php before place it into Code Snippets plugin. Currently, the code is still inside functions.php.

    I placed the shortcode ([mkp_activity]) in a page (link to the page as below). I also try to place the shortcode in widget area. But the loop just did not appear.

    Test Page

    function mkp_bp_activity_shortcode() {
    
    $message = 'testing 123';
    return $message;
    
    if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) :
        while ( bp_activities() ) : bp_the_activity();
    
            locate_template( array( 'activity/entry.php' ), true, false );
    
        endwhile;
    endif;
    
    }
    add_shortcode('mkp_activity', 'mkp_bp_activity_shortcode');

    I am new to this. I am not sure if I am doing this completely wrong. Appreciate any advice. Thanks!

    Regards,
    CK

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

  • Varun Dubey
    Participant

    @vapvarun


    cheekeat
    Participant

    @cheekeat

    Hi @vapvarun. Thanks for your suggestion. I have tried the plugin you suggested. There is another plugin (BuddyPress Activity Shortcode) I have also tried. But both plugins crashed my site upon activation. I have to remove them in safe mode.


    Varun Dubey
    Participant

    @vapvarun

    https://wordpress.org/plugins/shortcodes-for-buddypress/ and BuddyX both mine, seems working fine together, I have just tested on a template with preinstalled BuddyPress and Shortcode for Buddypress and BuddyX theme at https://tastewp.com/template/kXs6JdadkV0
    You can check in debug log for any errors and send that to our support we will check


    cheekeat
    Participant

    @cheekeat

    Hi @vapvarun, below is the error info that I copied from the fatal crash email. Hope it is helpful.

    ################
    When seeking help with this issue, you may be asked for some of the following information:
    WordPress version 5.8.3
    Current theme: BuddyX (version 4.2.8)
    Current plugin: Wbcom Designs – Shortcodes & Elementor Widgets For BuddyPress (version 2.4.0)
    PHP version 7.4.27

    Error Details
    =============
    An error of type E_ERROR was caused in line 444 of the file /home/mykepo/public_html/wp-content/plugins/shortcodes-for-buddypress/buddypress-shortcodes-element.php. Error message: Uncaught Error: Call to undefined function Elementor\bp_nouveau_before_activity_directory_content() in /home/mykepo/public_html/wp-content/plugins/shortcodes-for-buddypress/buddypress-shortcodes-element.php:444
    Stack trace:
    #0 /home/mykepo/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php(2172): Elementor\Buddypress_Shortcode_Activity_Widget->render()
    #1 /home/mykepo/public_html/wp-content/plugins/elementor/includes/base/widget-base.php(584): Elementor\Controls_Stack->render_by_mode()
    #2 /home/mykepo/public_html/wp-content/plugins/elementor/includes/base/widget-base.php(708): Elementor\Widget_Base->render_content()
    #3 /home/mykepo/public_html/wp-content/plugins/elementor/includes/base/element-base.php(534): Elementor\Widget_Base->get_raw_data(true)
    #4 /home/mykepo/public_html/wp-content/plugins/elementor/includes/base/element-base.php(534): Elementor\Element_Base->get_raw_data(true)
    #5 /home/mykepo/public_html/wp-content/plugins/elementor/core/base/document.php(876): Elementor\Element_
    ################


    Varun Dubey
    Participant

    @vapvarun

    @cheekeat please make sure you are using the Nouveau template
    BuddyX is best with the Nouveau template
    Setting >> BuddyPress >> Options


    cheekeat
    Participant

    @cheekeat

    Hi @vapvarun, yes, I am already using Nouveau template when setting up BuddyPress.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar