Search Results for 'Permalink post_id'
-
Search Results
-
I spent so long trawling google for an answer to this question, so i am sharing what i came up with. It might not be beautiful code (i patched it together from a number of sources), but it works for me.
Basically, i have a list of forums on my forum home page. I just wanted to show the latest post within each forum as a teaser below the forum description – not just the title, but the excerpt, too. I can’t believe there’s nothing out there explaining how to do this. It seems like a pretty obvious format for the forum index.
The following snippet will output the latest reply, with post title and post link below the forum description. If there are no replies, it will output the latest topic instead.
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 ); $other_args = array( 'post_type'=> 'topic', 'p' => $jag_last_topic_id ); $nest_query = new WP_Query( $new_args ); $another_nest_query = new WP_Query( $other_args ); 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_permalink= get_permalink(); ?> <a href="<?php echo $this_post_permalink; ?>"><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_content(); $this_post_permalink= get_permalink(); ?> <a href="<?php echo $this_post_permalink; ?>"><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');Just put this in your theme’s functions.php and it should do the trick. Haven’t figured out how to spit out multiple posts and replies for each forum yet, but this is all i needed. Good luck.
I set the permalink rule for Forum as below.
http://xxxxxxx.jp/forum/%post_id%/However,when log in as Subscriber/Contributor, the permalink rule isn’t reflected
but default setting(/%postname%/) is reflected…On the other hand, when log in as Admin, the permalink rule is reflected normally.
Could you tell me why this happens?
I’m setting Permalink rule for Forum as “http://xxxxxx.com/forums/forum/%post_id%/ “.
After Administrator created the forum, they can see the forum and post the topic/reply and
Permalink setting for them works properly.However, Subscriber and Contributer cannot see the forum Administrator created (Page not found screen shown). On top of that,
Permalink setting is changed only for Subscriber/Contributer as “http://xxxxxx.com/forums/forum/%post_name%/”.I have no idea why this happens… Could you kindly me the tips to solve the issue?
Hey guys,
I am putting up a topic to show how I have created the layout on http://teamoverpowered.com/forums/
My aim when creating the theme was to try and create a last poster block that would work throughout the forums and sub forums list.
custom_bbp_list_forums – this function creates the sub forums under the main forum
public function custom_bbp_list_forums( $args = '' ) { // Define used variables $output = $sub_forums = $topic_count = $reply_count = $counts = ''; $i = 0; $count = array(); // Defaults and arguments $defaults = array ( 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => ', ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true, 'show_freshness_link' => true, ); $r = bbp_parse_args( $args, $defaults, 'list_forums' ); extract( $r, EXTR_SKIP ); // Bail if there are no subforums if ( !bbp_get_forum_subforum_count( $forum_id ) ) return; // Loop through forums and create a list $sub_forums = bbp_forum_get_subforums( $forum_id ); if ( !empty( $sub_forums ) ) { // Total count (for separator) $total_subs = count( $sub_forums ); foreach ( $sub_forums as $sub_forum ) { $i++; // Separator count // Get forum details $count = array(); $show_sep = $total_subs > $i ? $separator : ''; $permalink = bbp_get_forum_permalink( $sub_forum->ID ); $title = bbp_get_forum_title( $sub_forum->ID ); // Show topic count if ( !empty( $show_topic_count ) && !bbp_is_forum_category( $sub_forum->ID ) ) { $count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID ); } // Show reply count if ( !empty( $show_reply_count ) && !bbp_is_forum_category( $sub_forum->ID ) ) { $count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID ); } // Counts to show if ( !empty( $count ) ) { $counts = $count_before . implode( $count_sep, $count ) . $count_after; } if ( !empty( $show_freshness_link ) ) { $freshness_link = "" . BBP_Default::teamop_get_last_poster_block( $sub_forum->ID ) . ""; } // Build this sub forums link if ($i % 2) { $class = "odd-forum-row"; } else { $class = "even-forum-row"; } $output .= "" . $link_before . '<a href="' . $permalink . '">' . $title . '</a>' . $counts . $freshness_link . $link_after . ""; } // Output the list echo apply_filters( 'bbp_list_forums', $before . $output . $after, $args ); } }I then call that function inside loop-single-forum.php like so:
BBP_Default::custom_bbp_list_forums( array ( 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'count_before' => 'Topics: ', 'count_after' => '', 'count_sep' => 'Posts: ', 'separator' => '', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true, 'show_freshness_link' => true, ));Inside the first function I am also calling a second custom function called custom_get_last_poster_block
function custom_get_last_poster_block( $subforum_id = "" ) { if ( !empty( $subforum_id ) ) { $output = ""; $output .= "<a href='". bbp_get_forum_last_topic_permalink( $subforum_id ) ."'>" . bbp_get_topic_last_reply_title( bbp_get_forum_last_active_id( $subforum_id ) ) . "</a>"; $output .= ""; $output .= "by "; $output .= bbp_get_author_link( array( "post_id" => $subforum_id, "size" => 14 ) ); $output .= ""; $output .= ""; $output .= bbp_get_forum_last_active_time( $subforum_id ); $output .= ""; } else { $output = ""; $output .= "<a href='". bbp_get_forum_last_topic_permalink() ."'>" . bbp_get_topic_last_reply_title( bbp_get_forum_last_active_id() ) . "</a>"; $output .= ""; $output .= "by "; $output .= bbp_get_author_link( array( "post_id" => bbp_get_forum_last_active_id(), "size" => 14 ) ); $output .= ""; $output .= ""; $output .= bbp_get_forum_last_active_time( bbp_get_forum_last_active_id() ); $output .= ""; } return $output; }This then creates my sub forum list, I added some extra classes in I can hook onto and display:none if need. I decided when creating me theme that I would get as much information showing as possible, then just use CSS to customise it.
The final functions is one I call inside loop-single-topic.php.
public function custom_get_last_poster_block_topics() { $output .= ""; $output .= bbp_get_author_link( array( "post_id" => bbp_get_forum_last_active_id(), "size" => 14 ) ); $output .= ""; $output .= ""; $output .= bbp_get_topic_last_active_time( bbp_get_topic_last_active_id() ); $output .= ""; return $output; }This is my final function and it just adds the last poster block inside the topics list.
If you need any more help then let me know.
UPDATE: Please see the following topic for updated code
I have created a bbPress starter theme with a phpBB look and feel
Topic: custom the forum permalinks
hi,
i am new to bbPress, and now playing with it in localhost.
i found the topic and reply etc’s permalink get the {post_name} in it, and i just want to change it to the {post_id}, i searched a lot, but not found any good solution.
maybe someone here could give me some advices?
thx,
Andor
Topic: Permalinks settings
Hello.
I set up permalinks in WordPress like this:
%year%/%monthnum%/%day%/%post_id%
but new topic in bbpress sounds like:
forum-topic/2012/02/New-theme-name
What am I doing wrong?
Thanx in advance.
Topic: Loading Time/ Permalinks
I looked at “http://codex.wordpress.org/Using_Permalinks”, it reads: “For performance reasons, it is not a good idea to start your permalink structure with the category, tag, author, or postname fields.”
I can’t seem to be able to use the recommended link structures with bbpress forums and topics such as /%post_id%/%postname%/.
Will the permalink structure greatly affect the loading time of my different pages or has this issue been resolved with the latest version of WordPress?
i found a bug,but i don’t know if it was fixed.
when i permalink is /archives/%post_id%.html,i couldn’t open my forum,but use default permalink,it is ok.
is any one also have the same problem?
;