Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'Permalink post_id'

Viewing 25 results - 1 through 25 (of 51 total)
  • Author
    Search Results
  • #214787
    acb93
    Participant

    Hi. I have a “little problem”.

    Im am using custom permalinks to the topics contents:

    Example:

    https://www.ggforo.com/foros/topic/%post_id%

    So everything is perfect using ID post on topics URL but… when a user tries to edit the post (no WP admin, inside the topic, a normal user) is redirected to the list of forums:

    https://www.ggforo.com/foros

    I Have no idea why this is happening. I tried to search which bbpress file need to modify or something but I have no luck for the moment…

    BBPress Version: 2.6.5
    Wordpress Version: 5.5.1

    If someone could help me I would appreciate it

    Regards.

    #204276
    Robin W
    Moderator

    If you just want to remove it from the list then you could amend loop-single-forum.php

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    find
    wp-content/plugins/bbpress/templates/default/bbpress/loop-single-forum.php
    Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/loop-single-forum.php
    bbPress will now use this template instead of the original
    and you can amend this

    change it to (assuming 40250 is the fiorum id)

    
    <?php
    
    /**
     * Forums Loop - Single Forum
     *
     * @package bbPress
     * @subpackage Theme
     */
    
    if ( !bbp_get_forum_id() == '40250')) {
    ?>
    
    <ul id="bbp-forum-<?php bbp_forum_id(); ?>" <?php bbp_forum_class(); ?>>
    
    	<li class="bbp-forum-info">
    
    		<?php if ( bbp_is_user_home() && bbp_is_subscriptions() ) : ?>
    
    			<span class="bbp-row-actions">
    
    				<?php do_action( 'bbp_theme_before_forum_subscription_action' ); ?>
    
    				<?php bbp_forum_subscription_link( array( 'before' => '', 'subscribe' => '+', 'unsubscribe' => '&times;' ) ); ?>
    
    				<?php do_action( 'bbp_theme_after_forum_subscription_action' ); ?>
    
    			</span>
    
    		<?php endif; ?>
    
    		<?php do_action( 'bbp_theme_before_forum_title' ); ?>
    
    		<a class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?>"><?php bbp_forum_title(); ?></a>
    
    		<?php do_action( 'bbp_theme_after_forum_title' ); ?>
    
    		<?php do_action( 'bbp_theme_before_forum_description' ); ?>
    
    		<div class="bbp-forum-content"><?php bbp_forum_content(); ?></div>
    
    		<?php do_action( 'bbp_theme_after_forum_description' ); ?>
    
    		<?php do_action( 'bbp_theme_before_forum_sub_forums' ); ?>
    
    		<?php bbp_list_forums(); ?>
    
    		<?php do_action( 'bbp_theme_after_forum_sub_forums' ); ?>
    
    		<?php bbp_forum_row_actions(); ?>
    
    	</li>
    
    	<li class="bbp-forum-topic-count"><?php bbp_forum_topic_count(); ?></li>
    
    	<li class="bbp-forum-reply-count"><?php bbp_show_lead_topic() ? bbp_forum_reply_count() : bbp_forum_post_count(); ?></li>
    
    	<li class="bbp-forum-freshness">
    
    		<?php do_action( 'bbp_theme_before_forum_freshness_link' ); ?>
    
    		<?php bbp_forum_freshness_link(); ?>
    
    		<?php do_action( 'bbp_theme_after_forum_freshness_link' ); ?>
    
    		<p class="bbp-topic-meta">
    
    			<?php do_action( 'bbp_theme_before_topic_author' ); ?>
    
    			<span class="bbp-topic-freshness-author"><?php bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'size' => 14 ) ); ?></span>
    
    			<?php do_action( 'bbp_theme_after_topic_author' ); ?>
    
    		</p>
    	</li>
    
    </ul><!-- #bbp-forum-<?php bbp_forum_id(); ?> -->
    
    <?php } ?>

    Not tested but should work, if not then might be another bbpress plugin overwriting the template – come back

    #198356
    hthornhillhww
    Participant

    Hi,

    I have created a custom notification for my site when a post is published, the code used to do this is :-

    // this is to add a fake component to BuddyPress. A registered component is needed to add notifications
    function custom_filter_notifications_get_registered_components( $component_names = array() ) {
        // Force $component_names to be an array
        if ( ! is_array( $component_names ) ) {
            $component_names = array();
        }
        // Add 'custom' component to registered components array
        array_push( $component_names, 'publishpost' );
        // Return component's with 'custom' appended
        return $component_names;
    }
    add_filter( 'bp_notifications_get_registered_components', 'custom_filter_notifications_get_registered_components' );
    
    // this hooks to post creation and saves the post id
    function bp_custom_add_notification( $post_id, $post ) {
            $post = get_post( $post_id );
            $author_id = $post->post_author;
    		
    		$blogusers = get_users( array( 'role' => 'staff' ) );
    		// Array of WP_User objects.
    		foreach ( $blogusers as $user ) {
    			bp_notifications_add_notification( array(
                'user_id'           => $user->id,
                'item_id'           => $post_id,
                'component_name'    => 'publishpost',
                'component_action'  => 'publishpost_action',
                'date_notified'     => bp_core_current_time(),
                'is_new'            => 1,
            ) );   
    		}        
    }
    add_action( 'publish_post', 'bp_custom_add_notification', 99, 2 );
    
    /**
     * Format the BuddyBar/Toolbar notifications
     *
     * @since bbPress (r5155)
     *
     * @package bbPress
     *
     * @param string $action The kind of notification being rendered
     * @param int $item_id The primary item id
     * @param int $secondary_item_id The secondary item id
     * @param int $total_items The total number of messaging-related notifications waiting for the user
     * @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
     */
    function custom_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) 
    {
    // New custom notifications
        if ( 'publishpost_action' === $action ) {
    
            $post = get_post( $item_id );
    		$author_name = get_the_author_meta('display_name', $post->post_author);
            $custom_title = bp_core_get_user_displayname( $post->post_author ) . ' published a new post "' . get_the_title( $item_id ) . '"';
            $custom_link  = get_permalink( $post );
            $custom_text = bp_core_get_user_displayname( $post->post_author ) . ' published a new post "' . get_the_title( $item_id ) . '"';
            // WordPress Toolbar
            if ( 'string' === $format ) {
                $return = apply_filters( 'publishpost_filter', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_title ) . '">' . esc_html( $custom_text ) . '</a>', $custom_text, $custom_link );
            // Deprecated BuddyBar
            } else {
                $return = apply_filters( 'publishpost_filter', array(
                    'text' => $custom_text,
                    'link' => $custom_link
                ), $custom_link, (int) $total_items, $custom_text, $custom_title );
            }
    
            return $return;
    
        } 
    	
    	if ( 'bbp_new_reply' === $action ) {
    		$topic_id    = bbp_get_reply_topic_id( $item_id );
    		$topic_title = bbp_get_topic_title( $topic_id );
    		$topic_link  = wp_nonce_url( add_query_arg( array( 'action' => 'bbp_mark_read', 'topic_id' => $topic_id ), bbp_get_reply_url( $item_id ) ), 'bbp_mark_topic_' . $topic_id );
    		$title_attr  = __( 'Topic Replies', 'bbpress' );
    
    		if ( (int) $total_items > 1 ) {
    			$text   = sprintf( __( 'You have %d new replies', 'bbpress' ), (int) $total_items );
    			$filter = 'bbp_multiple_new_subscription_notification';
    		} else {
    			if ( !empty( $secondary_item_id ) ) {
    				$text = sprintf( __( 'You have %d new reply to %2$s from %3$s', 'bbpress' ), (int) $total_items, $topic_title, bp_core_get_user_displayname( $secondary_item_id ) );
    			} else {
    				$text = sprintf( __( 'You have %d new reply to %s',             'bbpress' ), (int) $total_items, $topic_title );
    			}
    			$filter = 'bbp_single_new_subscription_notification';
    		}
    
    		// WordPress Toolbar
    		if ( 'string' === $format ) {
    			$return = apply_filters( $filter, '<a href="' . esc_url( $topic_link ) . '" title="' . esc_attr( $title_attr ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $text, $topic_link );
    
    		// Deprecated BuddyBar
    		} else {
    			$return = apply_filters( $filter, array(
    				'text' => $text,
    				'link' => $topic_link
    			), $topic_link, (int) $total_items, $text, $topic_title );
    		}
    
    		do_action( 'bbp_format_buddypress_notifications', $action, $item_id, $secondary_item_id, $total_items );
    
    		return $return;
    	}
    }
    add_filter( 'bp_notifications_get_notifications_for_user', 'custom_format_buddypress_notifications', 1, 5 );

    How can i create the same for a new bbpress topic? i’m thinking i need to change this code section but not sure how

    // this hooks to post creation and saves the post id
    function bp_custom_add_notification( $post_id, $post ) {
            $post = get_post( $post_id );
            $author_id = $post->post_author;
    		
    		$blogusers = get_users( array( 'role' => 'staff' ) );
    		// Array of WP_User objects.
    		foreach ( $blogusers as $user ) {
    			bp_notifications_add_notification( array(
                'user_id'           => $user->id,
                'item_id'           => $post_id,
                'component_name'    => 'publishpost',
                'component_action'  => 'publishpost_action',
                'date_notified'     => bp_core_current_time(),
                'is_new'            => 1,
            ) );   
    		}        
    }
    add_action( 'publish_post', 'bp_custom_add_notification', 99, 2 );

    I am using woffice as the theme, bbpress version 2.5.14, buddypress version 4.1.0 and the latest version of wordpress

    Thanks

    #198316
    hthornhillhww
    Participant

    Hi,

    I have created a custom notification for my site when a post is published, if i have buddypress activated alone i see the notification text but as soon as i activate bbpress i can no longer see the notification description. In order to work out this was happening when bbpress was activated i created a whole new blank install of wpress and only installed the two plugins and when i deactivated bbpress it showed the text.

    this is how the notification shows when bbpress is activated
    https://www.dropbox.com/s/uepps9cjcd8xan5/With%20BbPress%20no%20text.PNG?dl=0

    this is how the notification shows when bbpress is NOT activated
    https://www.dropbox.com/s/03wch6bc27nsked/Without%20BbPress%20showing%20text.PNG?dl=0

    I am using Twenty seventeen as the theme, bbpress version 2.5.14, buddypress version 4.1.0 and the latest version of wordpress

    The code i have used to generate the notification is below, and this is located in \wp-content\plugins\bp-custom.php

    <?php
    // this is to add a fake component to BuddyPress. A registered component is needed to add notifications
    function custom_filter_notifications_get_registered_components( $component_names = array() ) {
        // Force $component_names to be an array
        if ( ! is_array( $component_names ) ) {
            $component_names = array();
        }
        // Add 'custom' component to registered components array
        array_push( $component_names, 'publishpost' );
        // Return component's with 'custom' appended
        return $component_names;
    }
    add_filter( 'bp_notifications_get_registered_components', 'custom_filter_notifications_get_registered_components' );
    
    // this hooks to post creation and saves the post id
    function bp_custom_add_notification( $post_id, $post ) {
            $post = get_post( $post_id );
            $author_id = $post->post_author;
            bp_notifications_add_notification( array(
                'user_id'           => $author_id,
                'item_id'           => $post_id,
                'component_name'    => 'publishpost',
                'component_action'  => 'publishpost_action',
                'date_notified'     => bp_core_current_time(),
                'is_new'            => 1,
            ) );   
    }
    add_action( 'publish_post', 'bp_custom_add_notification', 99, 2 );
    
    function custom_format_buddypress_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) 
    {
    // New custom notifications
        if ( 'publishpost_action' === $action ) {
    
            $post = get_post( $item_id );
    
            $custom_title = $post->post_author . ' published a new post ' . get_the_title( $item_id );
            $custom_link  = get_permalink( $post );
            $custom_text = $post->post_author . ' published a new post ' . get_the_title( $item_id );
            // WordPress Toolbar
            if ( 'string' === $format ) {
                $return = apply_filters( 'publishpost_filter', '<a href="' . esc_url( $custom_link ) . '" title="' . esc_attr( $custom_title ) . '">' . esc_html( $custom_text ) . '</a>', $custom_text, $custom_link );
            // Deprecated BuddyBar
            } else {
                $return = apply_filters( 'publishpost_filter', array(
                    'text' => $custom_text,
                    'link' => $custom_link
                ), $custom_link, (int) $total_items, $custom_text, $custom_title );
            }
    
            return $return;
    
        }
    }
    add_filter( 'bp_notifications_get_notifications_for_user', 'custom_format_buddypress_notifications', 10, 5 );

    I need to get it so that when bbpress is activated i can see the custom notification description as we use bbpress for our forums

    #189511
    liderxlt
    Participant

    Thanks for answering…
    As I mentioned in the open topic today https://bbpress.org/forums/topic/do-not-see-the-topic-in-forum/ What I did was prepare an xml file with the information to upload in the forums , topic and replies.

    I am using the plugin all import to load because it allows me to use cron tasks daily, not overload the server and not rewrite what is already loaded.

    I can do the import and visualize it correctly in the dashboard. The problem is that it is not displayed in the frontend. As far as I could see the post_parent of the topic is 0 … It must be equal to _bbp_forum_id.

    These are the parameters for the topic:
    _bbp_topic_id = 2231
    _bbp_forum_id = 2229
    _bbp_reply_count = 0
    _bbp_voice_count = 1
    _bbp_forum_parent_id = 2229

    Parameters replies:
    _bbp_topic_id = 2231
    _bbp_forum_id = 2229
    the_reply_parent_topic_id = 2229

    The other parameters, such as Post Status, are already automated.
    The good thing about the import plugin is that it allows you to introduce functions in import http://www.wpallimport.com/documentation/advanced/execute-php/

    I leave an extract of the topic export, there you can see how it takes the values but not the post_parent one

    <title>2586/15</title>
    		<link>http://localhost/expedientes/forums/topic/2586-15/</link>
    		<pubDate>Fri, 19 Jan 2018 03:22:16 +0000</pubDate>
    		<dc:creator><![CDATA[liderxlt]]></dc:creator>
    		<guid isPermaLink="false">http://localhost/expedientes/forums/topic/2586-15/</guid>
    		<description></description>
    		<content:encoded><![CDATA[<p style="text-align: center;"><strong><span style="text-align: start;">
    <strong>CAUSA:</strong> JUICIO EJECUTIVO]]></content:encoded>
    		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
    		<wp:post_id>2113</wp:post_id>
    		<wp:post_date><![CDATA[2018-01-19 00:22:16]]></wp:post_date>
    		<wp:post_date_gmt><![CDATA[2018-01-19 03:22:16]]></wp:post_date_gmt>
    		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
    		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
    		<wp:post_name><![CDATA[2586-15]]></wp:post_name>
    		<wp:status><![CDATA[publish]]></wp:status>
    		<wp:post_parent>0</wp:post_parent>
    		<wp:menu_order>0</wp:menu_order>
    		<wp:post_type><![CDATA[topic]]></wp:post_type>
    		<wp:post_password><![CDATA[]]></wp:post_password>
    		<wp:is_sticky>0</wp:is_sticky>
    		<category domain="topic-tag" nicename="2586-15"><![CDATA[2586/15]]></category>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_activity_id]]></wp:meta_key>
    			<wp:meta_value><![CDATA[10]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_author_ip]]></wp:meta_key>
    			<wp:meta_value><![CDATA[120.000.001]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_last_active_time]]></wp:meta_key>
    			<wp:meta_value><![CDATA[2016-02-03]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_reply_count]]></wp:meta_key>
    			<wp:meta_value><![CDATA[0]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_voice_count]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_wp_page_template]]></wp:meta_key>
    			<wp:meta_value><![CDATA[default]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_forum_id]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1327]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[_bbp_forum_parent_id]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1327]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[post_parent]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1327]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[wp_get_post_parent_id]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1327]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key><![CDATA[parent_id]]></wp:meta_key>
    			<wp:meta_value><![CDATA[1327]]></wp:meta_value>
    		</wp:postmeta>
    	</item>

    Can it be solved with the correct function?
    Thanks for your time @netweb

    #189001
    peter-hamilton
    Participant

    Hi @brent0r
    I made the following adjustment in my child-theme´s loop-single-forum.php and styled with CSS.
    This code will place all elements in the right order to have simple CSS adjustments make it all work as expected.

    <?php
    
    /**
     * Forums Loop - Single Forum
     *
     * @package bbPress
     * Theme OrganicSquare
     * Child-theme of TwentySixteen
     */
    
    ?>
    
    <ul id="bbp-forum-<?php bbp_forum_id(); ?>" <?php bbp_forum_class(); ?>>
    
    <li class="bbp-forum-info">
    	<div class="forumtitle">
    		<?php do_action( 'bbp_theme_before_forum_title' ); ?>
    
    		<a class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?>" title="<?php bbp_forum_title(); ?>"><?php bbp_forum_title(); ?></a>
    
    		<?php do_action( 'bbp_theme_after_forum_title' ); ?>
    
    		<?php do_action( 'bbp_theme_before_forum_sub_forums' ); ?>
    
    		<div class="bbp-forum-content"><?php bbp_forum_content(); ?></div>
    		<?php do_action( 'bbp_theme_after_forum_sub_forums' ); ?>
    
    		<?php do_action( 'bbp_theme_before_forum_description' ); ?>
    
    		<?php do_action( 'bbp_theme_after_forum_description' ); ?>
    
    		<?php bbp_forum_row_actions(); ?></div>
    	</li>
    
    <li class="bbp-forum-topic-count">
    		<div class="topic-reply-counts">Topics: <span class="ismcounter"><?php bbp_forum_topic_count(); ?></span></div>
    		<div class="topic-reply-counts">Posts: <span class="ismcounter"><?php bbp_show_lead_topic() ? bbp_forum_reply_count() : bbp_forum_post_count(); ?></span></div>
    	</li>
    
    <li class="bbp-topic-freshness mob-hide-link-forum">
    	<?php do_action( 'bbp_theme_before_forum_freshness_link' ); ?>
    
    	<div class="freshness-author"><span class="fresh-avatar"><?php bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'type' => 'avatar', 'size' => '40' ) ); ?></span>
    
    	<div class="fresh"><h2><a href=" <?php bbp_forum_last_reply_url(); ?>" class="forumpostlink"><?php bbp_forum_last_reply_title(); ?></a></h2>
    	<span class="forumlist-name"><?php bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'type' => 'name' ) ); ?></span>
    	<span class="widgetlistdate"><?php bbp_forum_freshness_link(); ?></span></div>
    	<?php do_action( 'bbp_theme_after_forum_freshness_link' ); ?>
    	</div>
    </li>
    
    </ul><!-- #bbp-forum-<?php bbp_forum_id(); ?> -->
    #184680
    Robin W
    Moderator

    ok, so this is a search function – yes?

    If so, look at this code that I use with my private groups plugin to filter search results and see if you can make this work for you

    //this function filters to the bbp search function to allow only returns from allowed forums
    
    function pg_has_search_results( $args = '' ) {
    	
    	global $wp_rewrite;
    //start with code as per bbp search !
    	/** Defaults **************************************************************/
    
    	$default_post_type = array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() );
    
    	// Default query args
    	$default = array(
    		'post_type'           => $default_post_type,         // Forums, topics, and replies
    		'posts_per_page'      => bbp_get_replies_per_page(), // This many
    		'paged'               => bbp_get_paged(),            // On this page
    		'orderby'             => 'date',                     // Sorted by date
    		'order'               => 'DESC',                     // Most recent first
    		'ignore_sticky_posts' => true,                       // Stickies not supported
    		's'                   => bbp_get_search_terms(),     // This is a search
    	);
    
    	// What are the default allowed statuses (based on user caps)
    	if ( bbp_get_view_all() ) {
    
    		// Default view=all statuses
    		$post_statuses = array(
    			bbp_get_public_status_id(),
    			bbp_get_closed_status_id(),
    			bbp_get_spam_status_id(),
    			bbp_get_trash_status_id()
    		);
    
    		// Add support for private status
    		if ( current_user_can( 'read_private_topics' ) ) {
    			$post_statuses[] = bbp_get_private_status_id();
    		}
    
    		// Join post statuses together
    		$default['post_status'] = implode( ',', $post_statuses );
    
    	// Lean on the 'perm' query var value of 'readable' to provide statuses
    	} else {
    		$default['perm'] = 'readable';
    	}
    	
    	//PRIVATE GROUPS then loop to find allowable results
    	//bail from this part if there are no search terms, as otherwise it sorts the whole database and overflows memory
    	if (! bbp_get_search_terms() == '' ) {
    	//change page default to allow filter against all search results - otherwise allowed posts is only the first page of results ie whatever is in  bbp_get_replies_per_page()
    	$default['posts_per_page'] = -1;
    	$allowed_posts = private_groups_get_permitted_post_ids(new WP_Query( $default ));
    	// Then add allowed forum ids to the default query 
        $default['post__in'] = $allowed_posts;
    	if (empty ($allowed_posts )) $default['post__in'] = array(0) ;
    	//then set per page back (so that we get the correct pagination )
    	$default['posts_per_page'] = bbp_get_replies_per_page();
    	
    	}
    	
    	
    	
    	//then return to bbp search code
    	
    	/** Setup *****************************************************************/
    
    	// Parse arguments against default values
    	$r = bbp_parse_args( $args, $default, 'has_search_results' );
    
    	// Get bbPress
    	$bbp = bbpress();
    
    	// Call the query
    	if ( ! empty( $r['s'] ) ) {
    		$bbp->search_query = new WP_Query( $r );
    	}
    
    	// Add pagination values to query object
    	$bbp->search_query->posts_per_page = $r['posts_per_page'];
    	$bbp->search_query->paged          = $r['paged'];
    
    	// Never home, regardless of what parse_query says
    	$bbp->search_query->is_home        = false;
    
    	// Only add pagination is query returned results
    	if ( ! empty( $bbp->search_query->found_posts ) && ! empty( $bbp->search_query->posts_per_page ) ) {
    
    		// Array of arguments to add after pagination links
    		$add_args = array();
    
    		// If pretty permalinks are enabled, make our pagination pretty
    		if ( $wp_rewrite->using_permalinks() ) {
    
    			// Shortcode territory
    			if ( is_page() || is_single() ) {
    				$base = trailingslashit( get_permalink() );
    
    			// Default search location
    			} else {
    				$base = trailingslashit( bbp_get_search_results_url() );
    			}
    
    			// Add pagination base
    			$base = $base . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' );
    
    		// Unpretty permalinks
    		} else {
    			$base = add_query_arg( 'paged', '%#%' );
    		}
    
    		// Add args
    		if ( bbp_get_view_all() ) {
    			$add_args['view'] = 'all';
    		}
    
    		// Add pagination to query object
    		$bbp->search_query->pagination_links = paginate_links(
    			apply_filters( 'bbp_search_results_pagination', array(
    				'base'      => $base,
    				'format'    => '',
    				'total'     => ceil( (int) $bbp->search_query->found_posts / (int) $r['posts_per_page'] ),
    				'current'   => (int) $bbp->search_query->paged,
    				'prev_text' => is_rtl() ? '&rarr;' : '&larr;',
    				'next_text' => is_rtl() ? '&larr;' : '&rarr;',
    				'mid_size'  => 1,
    				'add_args'  => $add_args, 
    			) )
    		);
    
    		// Remove first page from pagination
    		if ( $wp_rewrite->using_permalinks() ) {
    			$bbp->search_query->pagination_links = str_replace( $wp_rewrite->pagination_base . '/1/', '', $bbp->search_query->pagination_links );
    		} else {
    			$bbp->search_query->pagination_links = str_replace( '&paged=1', '', $bbp->search_query->pagination_links );
    		}
    	}
    	//finally filter to return
    	// Return object
    	return apply_filters( 'pg_has_search_results', $bbp->search_query->have_posts(), $bbp->search_query );
    }
    
    add_filter ('bbp_has_search_results', 'pg_has_search_results') ; 
    #178639
    LevyImage
    Participant

    Hi,
    I’ve been struggling with a serious import problem since may 2016.
    Issue #1 My BBpress forums will not migrate properly with conventional WordPress import/export built in tool.
    Issue #2 When I use WP ALL Import (pro bundle) to get a CSV I can actually work with, and manually update the USER ID table and Forum ID and Parent ID, the import works (Forums and Topics are matched up properly) but tool>BBpress>recaculate will completely break the forum, I need to be able to recalculate once in a while… not being able to do this is a problem. And even to get the imports working I have to manually change IDs in the CSVs in order for the imports to match content up properly. And even when using vlookup in Excel, it is painstakingly difficult to manually create a dual reference column where column one is the old ID (for old website forum) and column two is the new ID (for new website forum). This is why I don’t have a fixed CSV for replies yet. I’ve thousands of them.

    Authors of WP ALL Import have been of no substantial help. Please any help because I’ve been paying for my old server and new server for months now and it’s gotten very expensive.

    Data columns including in Forum Export is:
    id Title Content Post Type Date Order Parent Slug Author Status _bbp_status _bbp_old_forum_id _bbp_forum_parent_id _bbp_forum_subforum_count _bbp_topic_count_hidden _vc_post_settings _bbp_status _yoast_wpseo_title _bbp_forum_id _bbp_last_topic_id _bbp_last_reply_id _bbp_last_active_id _bbp_last_active_time _bbp_topic_count _bbp_total_topic_count _bbp_reply_count _bbp_total_reply_count

    Data columns included in Topic Export is:
    "id Title Content Date Post Type Permalink _bbp_old_topic_id _bbp_reply_count _bbp_total_reply_count _bbp_author_ip _bbp_old_sticky_status _bbp_topic_id _bbp_forum_id _bbp_last_reply_id _bbp_last_active_id _bbp_last_active_time _bbp_voice_count _vc_post_settings vc_teaser Status Author Slug Order Parent Comment Status"

    Data columns included in Replies Export is:
    id Content Date Post Type Permalink Status Author Slug Parent Order Comment Status Ping Status _bbp_post_id _bbp_author_ip _vc_post_settings _bbp_activity_id _bbp_topic_id _bbp_forum_id

    For Forum’s I updated Author IDs.
    For Topic’s I updated Author IDs, Parent, and _bbp_forum_id

    After a successful import for these two post types,
    bbpress recalculate will completely break the posts’ hierarchy.

    I’ve yet to find a way to get replies to import successfully due to the shear number of replies and _bbp_topic_id’s I’d have to update the new IDs for.

    #170127
    rayjay
    Participant

    Make a child theme of the bbpress first.

    Then you need to edit the loop-single-topic.php file in your child theme to move the code below to replace the other code on the bottom..

    		<?php do_action( 'bbp_theme_before_topic_meta' ); ?>
    
    		<p class="bbp-topic-meta">
    
    			<?php do_action( 'bbp_theme_before_topic_started_by' ); ?>
    
    			<span class="bbp-topic-started-by"><?php printf( __( Started by: '%1$s', 'bbpress' ), bbp_get_topic_author_link( array( 'size' => '14' ) ) ); ?></span>
    
    			<?php do_action( 'bbp_theme_after_topic_started_by' ); ?>
    
    			<?php if ( !bbp_is_single_forum() || ( bbp_get_topic_forum_id() !== bbp_get_forum_id() ) ) : ?>
    
    				<?php do_action( 'bbp_theme_before_topic_started_in' ); ?>
    
    				<span class="bbp-topic-started-in"><?php printf( __( 'in: <a href="%1$s">%2$s</a>', 'bbpress' ), bbp_get_forum_permalink( bbp_get_topic_forum_id() ), bbp_get_forum_title( bbp_get_topic_forum_id() ) ); ?></span>
    
    				<?php do_action( 'bbp_theme_after_topic_started_in' ); ?>
    
    			<?php endif; ?>
    
    		</p>
    
    		<?php do_action( 'bbp_theme_after_topic_meta' ); ?>

    replace the abvoe code with below code..

    		<?php do_action( 'bbp_theme_before_topic_freshness_link' ); ?>
    
    		<?php bbp_topic_freshness_link(); ?>
    
    		<?php do_action( 'bbp_theme_after_topic_freshness_link' ); ?>
    
    		<p class="bbp-topic-meta">
    
    			<?php do_action( 'bbp_theme_before_topic_freshness_author' ); ?>
    
    			<span class="bbp-topic-freshness-author"><?php bbp_author_link( array( 'post_id' => bbp_get_topic_last_active_id(), 'size' => 14 ) ); ?></span>
    
    			<?php do_action( 'bbp_theme_after_topic_freshness_author' ); ?>
    
    		</p>
    #164256
    PinkishHue
    Participant

    @julia_b (If you’re still waiting for a reply!) – you need to put this in your functions.php file, more info here: https://codex.bbpress.org/functions-files-and-child-themes-explained/

    This works great, thanks so much for sharing this code!

    I’ve also managed, with very little tweaking, to get this displaying replies under topics within the topics list (this is very rough with some bits commented out but pasting here in case it helps someone)

    
    // https://bbpress.org/forums/topic/how-to-add-latest-reply-or-topic-to-forum-list/
    function jagreplies_add_last_reply() { { 
     $jagreplies_last_reply_id = bbp_get_topic_last_reply_id();
     //$jagreplies_last_topic_id = bbp_get_forum_last_topic_id();
    
    $new_args = array(
        'post_type'=> 'reply',
        'p' => $jagreplies_last_reply_id
    );
    $post_title_args = array(
        'post_type'=> 'topic',
        'p' => $jagreplies_last_topic_id
    );
    $other_args = array(
        'post_type'=> 'topic',
        'p' => $jagreplies_last_topic_id
    );
    $jagreplies_query = new WP_Query( $post_title_args );
    $nest_query = new WP_Query( $new_args );
    $another_nest_query = new WP_Query( $other_args );
    
       if ( $jagreplies_query->have_posts() ) : while ( $jagreplies_query->have_posts() ) : $jagreplies_query->the_post();
         $this_post_id=$post->ID;
         $this_post_permalink= get_permalink(); ?>   
                                 
         <!--<a href="<?php //echo $this_post_permalink; ?>">-->
    
    <?php endwhile; 
       endif; wp_reset_query();
    
       if ( $nest_query->have_posts() ) : while ( $nest_query->have_posts() ) : $nest_query->the_post();
         $this_post_id=$post->ID;
         //$this_post_title= get_the_title();
         //$this_post_content= get_the_excerpt(); 
         $this_post_content= the_content(); ?>
    
         <h1><?php echo $this_post_title; ?></h1></a>
         <div class="the_content"><?php echo $this_post_content; ?></div>
                         
       <?php endwhile;
    elseif ( $another_nest_query->have_posts() ) : while ( $another_nest_query->have_posts() ) : $another_nest_query->the_post();
         $this_post_id=$post->ID;
         //$this_post_title= get_the_title();
         //$this_post_content= get_the_excerpt();
         $this_post_content= the_content(); ?>   
                                      
         <!--<h1><?php //echo $this_post_title; ?></h1></a>-->
         <div class="the_content"><?php echo $this_post_content; ?></div>
                         
       <?php endwhile; 
       endif; 
        }} 
    // Hook into action
    add_action('bbp_theme_after_topic_freshness_author','jagreplies_add_last_reply');

    This is extremely useful in creating a ‘Facebook’ style site where all content can be displayed on one single page (I know, Facebook, yuck! But it’s what ‘the people’ like)

    Now I just need to try to get the bbpress Ajax Replies plugin working in conjunction with this so people can post and reply from that single page. Interesting!

    **edited to add – if using my code above you may just want to change the last line ‘bbp_theme_after_topic_freshness_author’ to a different hook depending on where you want to display it, I am using customised templates but I’m not sure how it would look loading the content there if using the default templates

    #161552
    Kolya Korobochkin
    Participant

    Hi. The ending / (trailing slash?) added automaticly if you setup something like /news/%POST_ID%/ on the WordPress permalinks page. And not be added if no slash at the end — /news/%POST_ID%. This works because I use user_trailingslashit() inside the code.

    BuddyPress group forums not supported yet. Something hardcoded inside and I not find the solution to this issue right now but I keep digging. 🙂

    wenlujon
    Participant

    ok, i got it (loop-replies.php):

                            <?php $count=1; while ( bbp_replies() ) : bbp_the_reply(); ?>
                                    <?php
                                             $post_id = get_the_ID();
                                             //save the new count
                                             update_post_meta($post_id, 'bbp_seq_test', $count) ;
                                    ?>
    
                                    <?php bbp_get_template_part( 'loop', 'single-reply' );
                                         
                                             $count = $count + 1 ;
                                    ?>
    
                            <?php endwhile; ?>
    

    and define a function show_seq()

    
          $post_id = get_the_ID();
          $count   = get_post_meta( $post_id, 'bbp_seq_test', true );
    
            echo $count;
    
    

    and then in loop-single-reply.php
    ` <a href=”<?php bbp_reply_url(); ?>” class=”bbp-reply-permalink”>#<?php show_seq(); ?></a>
    `

    and it works!

    please take a look!

    http://bbs.circday.com/forums/topic/%E6%B5%8B%E8%AF%95%E6%B0%B4%E5%8D%B0

    #161143
    wenlujon
    Participant

    I changed the permalinks in wordpress->dashboard->settting->permalinks to:
    /%year%/%monthnum%/%day%/%post_id%.html

    however, it doesn’t impact the forum at all! the link of topics in the forum are still shown as the title of the topic (I’m setting up a Chinese forum, the title of the topics would become some escaped characters).

    #156120
    Divine_Apex
    Participant

    I am currently experiencing a padding issue with mini avatar icon displays. For example, on the last post author among other things:

    [IMG]http://i.imgur.com/YYBQoHX.png[/IMG]

    I am using a custom avatar plugin and it seems users with blank avatars don’t have this padding issue. I have checked CSS and can’t seem to find where to mess with this padding or anything that seems to work.

    I am also using this code in my loop-single-forum file to display the topic title under the last post time

    <?php do_action( 'bbp_theme_before_topic_author' ); ?>
    
    			<div class="bbp-forum-last-topic-name"><a href="<?php bbp_forum_last_topic_permalink(); ?>" title="<?php bbp_forum_last_topic_title(); ?>"><?php bbp_forum_last_topic_title(); ?></a></div>
    <?php do_action( 'bbp_theme_before_topic_author' ); ?>
    <span class="bbp-topic-freshness-author"><?php bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'size' => 14 ) ); ?></span>
    
    			<?php do_action( 'bbp_theme_after_topic_author' ); ?>
    

    My site:
    http://the-divine.net/forum

    #154873

    In reply to: Photo in Latest posts

    Robkk
    Moderator

    in this code you pasted it looks like the exact code to display the avatars is already there.

    maybe you didnt install the template files right??

    wherever you see something like this below , this is what should be displaying the avatar

    ‘size’ => 14

    this is complete started by section showing the started by author avatar

    <?php do_action( ‘bbp_theme_before_topic_started_by’ ); ?>
    
    <?php
    if (class_exists(‘userpro_api’)) {
    /* Integrating UserPro */
    global $userpro;
    $link = preg_replace(“/(?<=href=(\”|’))[^\”‘]+(?=(\”|’))/”, $userpro->permalink( bbp_get_topic_author_id() ),
    bbp_get_topic_author_link( array( ‘size’ => 14 ) ) );
    } else {
    $link = bbp_get_topic_author_link( array( ‘size’ => ’14’ ) );
    }
    ?>
    
    <span class=”bbp-topic-started-by”><?php printf( __( ‘Started by: %1$s’, ‘bbpress’ ), $link ); ?></span>
    
    <?php do_action( ‘bbp_theme_after_topic_started_by’ ); ?>

    this is the complete freshness section showing the author avatar

    <?php do_action( ‘bbp_theme_before_topic_freshness_author’ ); ?>
    <?php
    if (class_exists(‘userpro_api’)) {
    global $userpro;
    $link = preg_replace(“/(?<=href=(\”|’))[^\”‘]+(?=(\”|’))/”, $userpro->permalink( bbp_get_topic_author_id( bbp_get_topic_last_active_id() ) ), bbp_get_author_link( array( ‘post_id’ => bbp_get_topic_last_active_id(), ‘size’ => 30 ) ) );
    } else {
    $link = bbp_get_author_link( array( ‘post_id’ => bbp_get_topic_last_active_id(), ‘size’ => 14 ) );
    }
    ?>
    
    <span class=”bbp-topic-freshness-author”><?php echo $link; ?></span>
    
    <?php do_action( ‘bbp_theme_after_topic_freshness_author’ ); ?>
    #154852

    In reply to: Photo in Latest posts

    Icaroferreira
    Participant

    Thank you.

    So, Please, where exactly I should enter these codes above, within my code I have in the folder: loop-single-topic.php

    see:

    <?php

    /**
    * Topics Loop – Single
    *
    * @package bbPress
    * @subpackage Theme
    */

    ?>

    <ul id=”bbp-topic-<?php bbp_topic_id(); ?>” <?php bbp_topic_class(); ?>>

    <li class=”bbp-topic-title”>

    <?php if ( bbp_is_user_home() ) : ?>

    <?php if ( bbp_is_favorites() ) : ?>

    <span class=”bbp-row-actions”>

    <?php do_action( ‘bbp_theme_before_topic_favorites_action’ ); ?>

    <?php bbp_topic_favorite_link( array( ‘before’ => ”, ‘favorite’ => ‘+’, ‘favorited’ => ‘×’ ) ); ?>

    <?php do_action( ‘bbp_theme_after_topic_favorites_action’ ); ?>

    </span>

    <?php elseif ( bbp_is_subscriptions() ) : ?>

    <span class=”bbp-row-actions”>

    <?php do_action( ‘bbp_theme_before_topic_subscription_action’ ); ?>

    <?php bbp_topic_subscription_link( array( ‘before’ => ”, ‘subscribe’ => ‘+’, ‘unsubscribe’ => ‘×’ ) ); ?>

    <?php do_action( ‘bbp_theme_after_topic_subscription_action’ ); ?>

    </span>

    <?php endif; ?>

    <?php endif; ?>

    <?php do_action( ‘bbp_theme_before_topic_title’ ); ?>

    “><?php bbp_topic_title(); ?>

    <?php do_action( ‘bbp_theme_after_topic_title’ ); ?>

    <?php bbp_topic_pagination(); ?>

    <?php do_action( ‘bbp_theme_before_topic_meta’ ); ?>

    <p class=”bbp-topic-meta”>

    <?php do_action( ‘bbp_theme_before_topic_started_by’ ); ?>

    <?php
    if (class_exists(‘userpro_api’)) {
    /* Integrating UserPro */
    global $userpro;
    $link = preg_replace(“/(?<=href=(\”|’))[^\”‘]+(?=(\”|’))/”, $userpro->permalink( bbp_get_topic_author_id() ),
    bbp_get_topic_author_link( array( ‘size’ => 14 ) ) );
    } else {
    $link = bbp_get_topic_author_link( array( ‘size’ => ’14’ ) );
    }
    ?>

    <span class=”bbp-topic-started-by”><?php printf( __( ‘Started by: %1$s’, ‘bbpress’ ), $link ); ?></span>

    <?php do_action( ‘bbp_theme_after_topic_started_by’ ); ?>

    <?php if ( !bbp_is_single_forum() || ( bbp_get_topic_forum_id() !== bbp_get_forum_id() ) ) : ?>

    <?php do_action( ‘bbp_theme_before_topic_started_in’ ); ?>

    <span class=”bbp-topic-started-in”><?php printf( __( ‘in: %2$s‘, ‘bbpress’ ), bbp_get_forum_permalink( bbp_get_topic_forum_id() ), bbp_get_forum_title( bbp_get_topic_forum_id() ) ); ?></span>

    <?php do_action( ‘bbp_theme_after_topic_started_in’ ); ?>

    <?php endif; ?>

    </p>

    <?php do_action( ‘bbp_theme_after_topic_meta’ ); ?>

    <?php bbp_topic_row_actions(); ?>

    <li class=”bbp-topic-voice-count”><?php bbp_topic_voice_count(); ?>

    <li class=”bbp-topic-reply-count”><?php bbp_show_lead_topic() ? bbp_topic_reply_count() : bbp_topic_post_count(); ?>

    <li class=”bbp-topic-freshness”>

    <?php //bbp_topic_freshness_link(); ?>

    <p class=”bbp-topic-meta”>

    <?php do_action( ‘bbp_theme_before_topic_freshness_author’ ); ?>
    <?php
    if (class_exists(‘userpro_api’)) {
    global $userpro;
    $link = preg_replace(“/(?<=href=(\”|’))[^\”‘]+(?=(\”|’))/”, $userpro->permalink( bbp_get_topic_author_id( bbp_get_topic_last_active_id() ) ), bbp_get_author_link( array( ‘post_id’ => bbp_get_topic_last_active_id(), ‘size’ => 30 ) ) );
    } else {
    $link = bbp_get_author_link( array( ‘post_id’ => bbp_get_topic_last_active_id(), ‘size’ => 14 ) );
    }
    ?>

    <span class=”bbp-topic-freshness-author”><?php echo $link; ?></span>

    <?php do_action( ‘bbp_theme_after_topic_freshness_author’ ); ?>

    </p>

    <!– #bbp-topic-<?php bbp_topic_id(); ?> –>

    #152942
    janfeng
    Participant
    #152940
    janfeng
    Participant

    How to Change Permalink Because It's a Localized Forum

    Use WordPress + bbpress , Permalink set to /%post_id% ,but still not work !!!

    Damn ,this BUG is two years ago >:-[


    @netweb
    @mercime

    janfeng
    Participant

    I install worpdress and bbpress , and set Permalink to /%post_id% .

    But not work ,Help ! I want use post_id in post.

    #147816
    Robin W
    Moderator

    Ok, what I want to do is check if the function is trying to filter and failing or not even trying to filter.

    I am therefore going to get the plugin to dump one of the lists, so that you can tell me what it is showing – it won’t look pretty, but should help.

    First of all you need to work out a search that produces only a few results, say less than 10, and that you can list all the results that you would expect to see for full access, and that you want to see for the private groups, and make a not of their numbers.

    so for instance

    search for zebra produces posts numbers

    2345,2367,2657,2894,2965

    But one of these is in a private forum so a non-logged in user should see

    2345,2367,2894,2965

    Once you have this list, then do the following :
    Use notepad to create a file called search.php

    then put this code into it

    <?php
    
    //this function filters to the bbp search function to allow only returns from allowed forums
    
    function pg_has_search_results( $args = '' ) {
    	global $wp_rewrite;
    //start with code as per bbp search !
    	/** Defaults **************************************************************/
    
    	$default_post_type = array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() );
    
    	// Default query args
    	$default = array(
    		'post_type'           => $default_post_type,         // Forums, topics, and replies
    		'posts_per_page'      => bbp_get_replies_per_page(), // This many
    		'paged'               => bbp_get_paged(),            // On this page
    		'orderby'             => 'date',                     // Sorted by date
    		'order'               => 'DESC',                     // Most recent first
    		'ignore_sticky_posts' => true,                       // Stickies not supported
    		's'                   => bbp_get_search_terms(),     // This is a search
    	);
    
    	// What are the default allowed statuses (based on user caps)
    	if ( bbp_get_view_all() ) {
    
    		// Default view=all statuses
    		$post_statuses = array(
    			bbp_get_public_status_id(),
    			bbp_get_closed_status_id(),
    			bbp_get_spam_status_id(),
    			bbp_get_trash_status_id()
    		);
    
    		// Add support for private status
    		if ( current_user_can( 'read_private_topics' ) ) {
    			$post_statuses[] = bbp_get_private_status_id();
    		}
    
    		// Join post statuses together
    		$default['post_status'] = implode( ',', $post_statuses );
    
    	// Lean on the 'perm' query var value of 'readable' to provide statuses
    	} else {
    		$default['perm'] = 'readable';
    	}
    	
    	//PG then loop to find allowable forums
    	//Get an array of IDs which the current user has permissions to view
    	$allowed_posts = private_groups_get_permitted_post_ids(new WP_Query($default));
    	Echo 'Allowed posts list' ;
    	var_dump ($allowed_posts) ;
    	// The default forum query with allowed forum ids array added
        $default['post__in'] = $allowed_posts;
    
        
    	//then return to bbp search code
    	/** Setup *****************************************************************/
    
    	// Parse arguments against default values
    	$r = bbp_parse_args( $args, $default, 'has_search_results' );
    
    	// Get bbPress
    	$bbp = bbpress();
    
    	// Call the query
    	if ( ! empty( $r['s'] ) ) {
    		$bbp->search_query = new WP_Query( $r );
    	}
    
    	// Add pagination values to query object
    	$bbp->search_query->posts_per_page = $r['posts_per_page'];
    	$bbp->search_query->paged          = $r['paged'];
    
    	// Never home, regardless of what parse_query says
    	$bbp->search_query->is_home        = false;
    
    	// Only add pagination is query returned results
    	if ( ! empty( $bbp->search_query->found_posts ) && ! empty( $bbp->search_query->posts_per_page ) ) {
    
    		// Array of arguments to add after pagination links
    		$add_args = array();
    
    		// If pretty permalinks are enabled, make our pagination pretty
    		if ( $wp_rewrite->using_permalinks() ) {
    
    			// Shortcode territory
    			if ( is_page() || is_single() ) {
    				$base = trailingslashit( get_permalink() );
    
    			// Default search location
    			} else {
    				$base = trailingslashit( bbp_get_search_results_url() );
    			}
    
    			// Add pagination base
    			$base = $base . user_trailingslashit( $wp_rewrite->pagination_base . '/%#%/' );
    
    		// Unpretty permalinks
    		} else {
    			$base = add_query_arg( 'paged', '%#%' );
    		}
    
    		// Add args
    		if ( bbp_get_view_all() ) {
    			$add_args['view'] = 'all';
    		}
    
    		// Add pagination to query object
    		$bbp->search_query->pagination_links = paginate_links(
    			apply_filters( 'bbp_search_results_pagination', array(
    				'base'      => $base,
    				'format'    => '',
    				'total'     => ceil( (int) $bbp->search_query->found_posts / (int) $r['posts_per_page'] ),
    				'current'   => (int) $bbp->search_query->paged,
    				'prev_text' => is_rtl() ? '&rarr;' : '&larr;',
    				'next_text' => is_rtl() ? '&larr;' : '&rarr;',
    				'mid_size'  => 1,
    				'add_args'  => $add_args, 
    			) )
    		);
    
    		// Remove first page from pagination
    		if ( $wp_rewrite->using_permalinks() ) {
    			$bbp->search_query->pagination_links = str_replace( $wp_rewrite->pagination_base . '/1/', '', $bbp->search_query->pagination_links );
    		} else {
    			$bbp->search_query->pagination_links = str_replace( '&paged=1', '', $bbp->search_query->pagination_links );
    		}
    	}
    	//finally filter to return
    	// Return object
    	return apply_filters( 'pg_has_search_results', $bbp->search_query->have_posts(), $bbp->search_query );
    }
    
    add_filter ('bbp_has_search_results', 'pg_has_search_results') ; 

    Then go into FTP

    Then look in

    wp-content/plugins/bbp-private-groups/includes

    and you’ll see a file called

    wp-content/plugins/bbp-private-groups/includes/search.php

    Rename this file to searchold.php (as we’ll need it back later!)

    Then copy the search.php that you made above to this folder (wp-content/plugins/bbp-private-groups/includes).

    Then run your search.

    You should see a horrible list at the start, but this will be what should be the filtered list

    run this with full access and with restricted access (ie not logged in) and tell me what lists you get and of they are different.

    #147489
    Robkk
    Moderator

    nevermind i pretty much got it

    looked at https://bbpress.org/forums/topic/freshness-link/

    used <?php bbp_forum_last_topic_title(); ?> to get the title of the last recent topic

    and some code i had that robin gave me some time ago

    end function is this

    <div class="bbp-forum-last-topic-name"><a href="<?php bbp_forum_last_topic_permalink(); ?>" title="<?php bbp_forum_last_topic_title(); ?>"><?php bbp_forum_last_topic_title(); ?></a></div>
    <span class="bbp-last-post-by-author"><?php printf( __( '%1$s', 'bbpress' ),bbp_get_forum_freshness_link( array() ) ); ?></span>
    <?php _e(' by ', 'bbp'); ?>
    <span class="bbp-forum-freshness-author"><?php bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'size' => 14 ) ); ?></span>
    #146595
    janfeng
    Participant

    Trying let Bbpress’s permalink use /%post_id% .

    #146594
    janfeng
    Participant

    @robin-w I want to Bbpress’s permalink use /%post_id% ,

    Like : https://bbpress.org/forums/topic/1532/

    Not a : https://bbpress.org/forums/topic/bbpress-use-post_id-how

    T_T…

    #146592
    janfeng
    Participant

    @robin-w Thank you for your reply.

    I want Bbpress always use /%post_id%/, without affecting wordpress set (Because my wordpress set to /%postname%/).

    My situation is quite similar with aisajib. So bbpress must be set to /% post_id% /, but wordpress unaffected.

    Sorry for my English, I hope you can understand what i mean.

    #146543
    Yukon Cornelius
    Participant

    update: this was undesirable because the link to the reply was going to the reply itself, which is just a single post of the ‘reply’ custom post type. I have created this dodgy hack of the above code so the permalink for the replies is still the topic permalink. I’m sure there are a million better ways to do this, but it does the job for me so i thought i’d share the updated version.

    function jag_add_last_reply() { { 
     $jag_last_reply_id = bbp_get_forum_last_reply_id();
     $jag_last_topic_id = bbp_get_forum_last_topic_id();
    
    $new_args = array(
        'post_type'=> 'reply',
        'p' => $jag_last_reply_id
    );
    $post_title_args = array(
        'post_type'=> 'topic',
        'p' => $jag_last_topic_id
    );
    $other_args = array(
        'post_type'=> 'topic',
        'p' => $jag_last_topic_id
    );
    $jag_query = new WP_Query( $post_title_args );
    $nest_query = new WP_Query( $new_args );
    $another_nest_query = new WP_Query( $other_args );
    
       if ( $jag_query->have_posts() ) : while ( $jag_query->have_posts() ) : $jag_query->the_post();
         $this_post_id=$post->ID;
         $this_post_permalink= get_permalink(); ?>   
                                 
         <a href="<?php echo $this_post_permalink; ?>">
    
    <?php endwhile; 
       endif; wp_reset_query();
    
       if ( $nest_query->have_posts() ) : while ( $nest_query->have_posts() ) : $nest_query->the_post();
         $this_post_id=$post->ID;
         $this_post_title= get_the_title();
         $this_post_content= get_the_excerpt(); ?>
                                 
         <h1><?php echo $this_post_title; ?></h1></a>
         <div class="the_content"><?php echo $this_post_content; ?></div>
                         
       <?php endwhile;
    elseif ( $another_nest_query->have_posts() ) : while ( $another_nest_query->have_posts() ) : $another_nest_query->the_post();
         $this_post_id=$post->ID;
         $this_post_title= get_the_title();
         $this_post_content= get_the_excerpt(); ?>   
                                 
         <h1><?php echo $this_post_title; ?></h1></a>
         <div class="the_content"><?php echo $this_post_content; ?></div>
                         
       <?php endwhile; 
       endif; 
        }} 
    // Hook into action
    add_action('bbp_theme_after_forum_description','jag_add_last_reply');
Viewing 25 results - 1 through 25 (of 51 total)
Skip to toolbar