Search Results for 'Permalink post_id'
-
AuthorSearch Results
-
May 19, 2014 at 12:45 pm #146592
In reply to: Bbpress use post_id , how ?
janfengParticipant@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.
May 18, 2014 at 5:13 pm #146543In reply to: How to add latest reply or topic to forum list
Yukon CorneliusParticipantupdate: 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');
May 18, 2014 at 4:04 pm #146539Topic: How to add latest reply or topic to forum list
in forum TroubleshootingYukon CorneliusParticipantI 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.
March 5, 2014 at 4:56 am #143281In reply to: how can i show latest thred
Robin WModeratorok, so drop the following into your functions file
// Display just latest topic function display_latest_topic() { $topics_query = array( 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $settings['parent_forum'], 'posts_per_page' => '1', 'post_status' => array( bbp_get_public_status_id(), bbp_get_closed_status_id() ), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'order' => 'DESC' ); $lt_query = new WP_Query( $topics_query ); while ( $lt_query->have_posts() ) { $lt_query->the_post(); $topic_id = bbp_get_topic_id( $lt_query->post->ID ); ?> <h2> Latest topic </h2> <h3> <a href="<?php bbp_reply_url(); ?>" class="bbp-reply-permalink"><?php bbp_topic_title($topic_id); ?></a></h3> <div id="bbpress-forums"> <div id="post-<?php bbp_reply_id(); ?>" class="bbp-reply-header"> <div class="bbp-meta"> <span class="bbp-reply-post-date"><?php bbp_reply_post_date(); ?></span> <a href="<?php bbp_reply_url(); ?>" class="bbp-reply-permalink">#<?php bbp_reply_id($topic_id); ?></a> </div><!-- .bbp-meta --> </div><!-- #post-<?php bbp_reply_id(); ?> --> <div <?php bbp_reply_class(); ?>> <div class="bbp-reply-author"> <?php bbp_reply_author_link( array( 'post_id' => $topic_id, 'sep' => '<br />', 'show_role' => true ) ); ?> </div><!-- .bbp-reply-author --> <div class="bbp-reply-content"> <?php bbp_reply_content(); ?> </div><!-- .bbp-reply-content --> </div><!-- .reply --> </div><!--div bbpress-forums---> <?php } }
and then on your page template add this function where you want it. I’ve wrapped it in an if is_front_page statement so it only shows on the frontpage. You night need to use is_home instead depending on how your blog is set up.
If you want it in the body, you should put it within the content div, either before or after the loop depending if you want it at the of or bottom of the page. You may need to play a bit !
February 12, 2014 at 2:03 am #142391In reply to: WP_Query post type topic help
hitkidParticipant*edit*
I’ve tried all of the documentations functions*<?php $args = array( ‘post_type’ => ‘topic’, ‘posts_per_page’ => 10 ); $the_query = new WP_Query( $args );?> <?php if ( $the_query->have_posts() ) : ?> <!– pagination here –> <!– the loop –> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php bbp_author_link( array( ‘post_id’ => bbp_get_forum_last_active_id(), ‘size’ => 32 ) ); ?> <a class=”bbp-topic-permalink” href=”<?php bbp_topic_permalink(); ?>” title=”<?php bbp_topic_title(); ?>”><?php bbp_topic_title(); ?></a> <?php endwhile; ?> <!– end of the loop –> <!– pagination here –> <?php wp_reset_postdata(); ?> <?php else: ?> <p><?php _e( ‘Sorry, no posts matched your criteria.’ ); ?></p> <?php endif; ?>
February 12, 2014 at 2:01 am #142390In reply to: WP_Query post type topic help
hitkidParticipantI don’t need their role or title. For some reason the avatars will just not come up in the loop outside of the mychild/bbpress/loop-single-forum.php files and mychild/bbpress/loop-single-topic.php. So it works fine on index pages.
I’ve tried all of the but nothing
Here’s what the code looks like right now:
<?php $args = array( 'post_type' => 'topic', 'posts_per_page' => 10 ); $the_query = new WP_Query( $args );?> <?php if ( $the_query->have_posts() ) : ?> <!-- pagination here --> <!-- the loop --> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'size' => 32 ) ); ?> <a class="bbp-topic-permalink" href="<?php bbp_topic_permalink(); ?>" title="<?php bbp_topic_title(); ?>"><?php bbp_topic_title(); ?></a> <?php endwhile; ?> <!-- end of the loop --> <!-- pagination here --> <?php wp_reset_postdata(); ?> <?php else: ?> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <?php endif; ?>
This worked for getting the original post author, but I need the latest active poster to appear
<?php echo get_avatar( get_the_author_meta( 'ID' ), 32 ); ?>
Is there a wordpress function equivalent for this function: bbp_get_forum_last_active_id() that I can use with get_avatar() ?
What file do these functions reside in? Maybe I could copy the functions out and make new ones in mychild/functions.php or see if something wrong and replace the file?
Thank you for the help!
October 29, 2013 at 9:55 pm #138558In reply to: Freshness of the forums list as a normal date
baylockParticipantOk, thank you!
I achieved what I wanted, this way:
Forums list:
<p class="bbpx-topic-meta"> <?php $forum_id = bbp_get_forum_id(); $last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true ); if ( empty( $last_active ) ) { $reply_id = bbp_get_forum_last_reply_id( $forum_id ); if (!empty( $reply_id)){$last_active = get_post_field( 'post_date', $reply_id );} else { $topic_id = bbp_get_forum_last_topic_id( $forum_id ); if (!empty( $topic_id)){$last_active = bbp_get_topic_last_active_time( $topic_id );}; }; }; $date= date('d/m/Y',bbp_convert_date( $last_active )); $active_id = bbp_get_forum_last_active_id( $forum_id ); $link_url = $title = ''; //these two next lines are beyond me: same condition, two results for the same variable... if (empty($active_id)){$active_id = bbp_get_forum_last_reply_id( $forum_id );}; if (empty($active_id)){$active_id = bbp_get_forum_last_topic_id( $forum_id );}; if (bbp_is_topic($active_id)) { $link_url = bbp_get_forum_last_topic_permalink( $forum_id ); $title = bbp_get_forum_last_topic_title( $forum_id ); } elseif (bbp_is_reply($active_id)) { $link_url = bbp_get_forum_last_reply_url( $forum_id ); $title = bbp_get_forum_last_reply_title( $forum_id ); }; $time_since = bbp_get_forum_last_active_time( $forum_id ); if (!empty($time_since) && !empty($link_url) { $anchor = '<a href="'.esc_url($link_url).'" title="'.esc_attr($title).'">'.$date.'</a>'; ?> <span class="bbp-topic-freshness-author"> <?php bbp_author_link(array('post_id'=>bbp_get_forum_last_active_id(),'size'=> 14)); ?> </span> <?php } else {$anchor = 'esc_html__( 'No Topics', 'bbpress' );}; ?> </p> <?php echo apply_filters( 'bbp_get_post_time', $anchor, $forum_id, $time_since, $link_url, $title, $active_id ); ?>
Topics list:
<p class="bbp-topic-meta"> <span class="bbp-topic-freshness-author"><?php bbp_author_link(array('post_id =>bbp_get_topic_last_active_id(),'size'=>14)); ?></span> <?php $topic_id = bbp_get_topic_id(); $reply_id = bbp_get_topic_last_reply_id(); $title = bbp_get_topic_last_reply_title( $topic_id ); $link_url = bbp_get_topic_last_reply_url( $topic_id ); $date = get_post_time( 'd/m/Y', $gmt, $reply_id, true ); $anchor = '<a href="'.esc_url($link_url).'" title="'.esc_attr($title).'">'.esc_html($date).'</a>'; echo apply_filters( 'bbp_get_topic_freshness_link', $anchor, $reply_id, $result, $link_url, $title ); ?> </p>
As you can see, I didn’t hook anything already. So far I just got rid of the “bbp_topic_freshness_link()” in the templates and simply replaced the initial function by these lines, just to make a test. I still have to make a function out of these.
Not happy with this mess as I’m sure it’s more complicated that it should be, but it works.
Thank you for your guidance koendb!
October 5, 2013 at 4:31 pm #137770In reply to: Freshness Link
CC-CailinParticipantHey, I modified it a little to fit the needs of my forum…
I can’t show you the link as I’m working on localhost at the moment, but here is what I did.Inside loop-single-forum.php, I removed this:
<?php do_action( 'bbp_theme_before_forum_freshness_link' ); ?> <?php bbp_forum_freshness_link(); ?> <?php do_action( 'bbp_theme_after_forum_freshness_link' ); ?>
And placed this in it’s place:
<a class="bbp-forum-freshness" href="<?php bbp_forum_permalink(); ?>"> <?php bbp_forum_last_topic_title(); ?></a> (<?php bbp_forum_last_active_time(); ?>) by <span class="bbp-topic-freshness-author"><?php bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'size' => 14 ) ); ?></span>
Now the last step I need help with is…
Right now if a forum doesn’t have posts in it yet, it shows the time I created the forum. Which is very weird. So what I i need is a php if/else code that would check if there is a forum_last_topic if there is, it must show my code… if there isn’t, it must show the text “No topics yet”. How do I do this? I have very basic php knowledgeSeptember 18, 2013 at 3:39 pm #137228In reply to: bbPress 2.4 // ERROR // Search stopped working…
pm2tParticipant+1 had the same problem on WP 3.6.1; BP 2.4; Better WP Security 3.5.6
after playing with the permalinks as suggested, I’ve found a workaround. I was using the numeric setting on permalinks. I’ve tried with others options, and search worked. I noticed that all others permalinks ended with a /. I selected custom structure field and included a / in the end of the numeric link: /archives/%post_id%/
bbpress is now working again for me. hope it helps others…
[]s
September 5, 2013 at 2:30 am #136734In reply to: bbPress 2.4 Now Available
tina_skParticipantHi, i have problem with the patch – ticket 2319
in this code:
<?php while ( $widget_query->have_posts() ) : $widget_query->the_post(); $topic_id = bbp_get_topic_id( $widget_query->post->ID ); $author_link = ''; // Maybe get the topic author if ( 'on' === $settings['show_user'] ) : if ( $settings['show_user'] ) : $author_link = bbp_get_topic_author_link( array( 'post_id' => $topic_id, 'type' => 'both', 'size' => 14 ) ); <?php endif; ?> <li> <a class="bbp-forum-title" href="<?php bbp_topic_permalink( $topic_id ); ?>"><?php bbp_topic_title( $topic_id ); ?></a> <?php if ( ! empty( $author_link ) ) : ?> <?php printf( _x( 'by %1$s', 'widgets', 'bbpress' ), '<span class="topic-author">' . $author_link . '</span>' ); ?> <?php endif; ?> <?php if ( 'on' === $settings['show_date'] ) : ?> <?php if ( $settings['show_date'] ) : ?> <div><?php bbp_topic_last_active_time( $topic_id ); ?></div> <?php endif; ?> </li> <?php endwhile; ?>
Parse error: syntax error, unexpected T_ENDWHILE in /home/.sites/261/site2485/web/forum/wp-content/plugins/bbpress/includes/common/widgets.php on line 829
Can you help me; what´s wrong?
April 16, 2013 at 12:03 am #133236In reply to: bbPress 2.3 now available!
realhoodParticipantWhat do you have your permalinks set to? (‘Settings’ -> ‘Permalinks’)
http://127.0.0.1/%post_id%.html
What is the ‘Search Slug’ for bbPress set to? (‘Settings’ -> ‘Forums’ )
using it→no issues (i don’t know why ,but it works)
not using →issues
mysite=wp+bbpress+buddypress
January 8, 2013 at 10:12 am #124920satochanParticipantI 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?
January 4, 2013 at 1:32 pm #124759satochanParticipantModify: Please omit “”” after /%post_id%/
January 4, 2013 at 1:30 pm #124758satochanParticipantI’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?
May 21, 2012 at 9:06 am #113715In reply to: custom recent activity column
LynqParticipantHi deathbybear,
The only way I have found to make this happen is to edit the core code provided by bbpress.
I am not sure if this is the right way to go, so if someone else can suggest another way then let me know.
Here is what I have done. I replaced the bbp_list_forums function inside forum-template.php and then inside the loops-single-forum I changed the arguments to enable the last poster.
function 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' => '<ul class="bbp-forums">',
'after' => '</ul>',
'link_before' => '<li class="bbp-forum">',
'link_after' => '</li>',
'count_before' => ' (',
'count_after' => ')',
'count_sep' => ', ',
'separator' => ', ',
'forum_id' => '',
'show_topic_count' => true,
'show_reply_count' => true,
'freshness_before' => '<td class="last-posted-box">',
'freshness_after' => '</td>',
'show_freshness_link' => true,
'freshness_author_before' => '<div class="author-box">',
'freshness_author_after' => '</div>'
);
$r = wp_parse_args( $args, $defaults );
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
if ( $sub_forums = bbp_forum_get_subforums( $forum_id ) ) {
// 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;
// Show topic count
if ( !empty( $show_freshness_link ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
$freshness_link = bbp_get_forum_freshness_link( $sub_forum->ID );
$freshness_author = $freshness_author_before . bbp_get_author_link( array( 'post_id' => bbp_get_forum_last_active_id( $sub_forum->ID ), 'size' => 14 ) ) . $freshness_author_after;
$freshness_link = $freshness_before . $freshness_link . $freshness_author . $freshness_after;
}
// Build this sub forums link
$output .= $link_before . '<a href="' . $permalink . '" class="bbp-forum-link">' . $title . $counts . $freshness_link . '</a>' . $show_sep . $link_after;
}
// Output the list
echo $before . $output . $after;
}
}Let me know how you get on, good luck!
May 18, 2012 at 2:48 pm #108142In reply to: Layout bbPress as Invision or phpBB or vBulletin
LynqParticipantfunction 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' => '<ul class="bbp-forums">',
'after' => '</ul>',
'link_before' => '<li class="bbp-forum">',
'link_after' => '</li>',
'count_before' => ' (',
'count_after' => ')',
'count_sep' => ', ',
'separator' => ', ',
'forum_id' => '',
'show_topic_count' => true,
'show_reply_count' => true,
'freshness_before' => '<td class="last-posted-box">',
'freshness_after' => '</td>',
'show_freshness_link' => true,
'freshness_author_before' => '<div class="author-box">',
'freshness_author_after' => '</div>'
);
$r = wp_parse_args( $args, $defaults );
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
if ( $sub_forums = bbp_forum_get_subforums( $forum_id ) ) {
// 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;
// Show topic count
if ( !empty( $show_freshness_link ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
$freshness_link = bbp_get_forum_freshness_link( $sub_forum->ID );
$freshness_author = $freshness_author_before . bbp_get_author_link( array( 'post_id' => bbp_get_forum_last_active_id( $sub_forum->ID ), 'size' => 14 ) ) . $freshness_author_after;
$freshness_link = $freshness_before . $freshness_link . $freshness_author . $freshness_after;
}
// Build this sub forums link
$output .= $link_before . '<a href="' . $permalink . '" class="bbp-forum-link">' . $title . $counts . $freshness_link . '</a>' . $show_sep . $link_after;
}
// Output the list
echo $before . $output . $after;
}
}This will give you more control over creating a theme which looks like Invision or PHPBB.
You will have to customize your theme as well to make sure it is compatible.
March 30, 2012 at 1:04 pm #43826Topic: custom the forum permalinks
in forum Troubleshootingandor_chenMemberhi,
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
February 13, 2012 at 7:26 pm #42263Topic: Permalinks settings
in forum Troubleshootingpau-bbpParticipantHello.
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.
January 4, 2012 at 4:54 am #111241In reply to: First installation. OMG!
Tammy HartMemberNeolo7, try setting your permalinks to something other than default. You should at least have %postname%.
To add /forums/ to your menu, use the custom links option. Or create a page and use the [bbp-forum-index] shortcode, then add that page to the menu.
There is a glitch that is not bbpress related, but rather it’s custom post types related. If you theme relies on the class “current_page_parent” to highlight the current page, WordPress things any post type should keep your blog page highlighted, if you have one. Here’s a piece of code you can drop in functions.php to help:
// fix menus
function support_menu_item($menu){
global $post;
if (get_post_type($post->ID) == 'forum' || get_post_type($post->ID) == 'topic' || get_post_type($post_id) == 'reply')
{
$menu = str_replace( 'current_page_parent', '', $menu ); // remove all current_page_parent classes
$menu = str_replace( 'menu-item-169', 'menu-item-169 current_page_parent', $menu ); // add the current_page_parent class to the page you want
}
return $menu;
}
add_filter( 'nav_menu_css_class', 'support_menu_item', 0 );
Be sure to change “169” to the id of your menu item.
September 21, 2011 at 7:42 pm #40046Topic: Loading Time/ Permalinks
in forum Troubleshootingrobot6MemberI 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?
May 27, 2011 at 12:00 am #38614Topic: i found a bug,but i don't know if it was fixed
in forum TroubleshootingmatchboxMemberi 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?
December 5, 2010 at 12:09 pm #77535In reply to: All RSS Feeds Broken?
LazzaParticipantI think I’ve created a quite strong code for the RSS. It allows plugins to apply their filters (example: smilies!!!). It fixes problems with double apersand encoding and ” ” not working well with UTF-8. It also fixes the date of items which is not valid if you use localization, even if the options array sets “false” on “localize”.
Feel free to try the code for yourself, it works with stock bbPress 1.0.2. You JUST need to put this content in your rss2.php (check the theme folder).
<?php
header( 'Content-Type: text/xml; charset=UTF-8' );
echo '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "n";
bb_generator( 'comment' );
function datefix($buffer) {
/*
* fix della data in modo da tenerla in inglese, rispettando
* le specifiche dei feed RSS
*/
return gmdate('D, d M Y H:i:s +0000', $buffer);
}
function callback($buffer)
{
/*
* sistema il codice rimuovendo la doppia codifica di "&" e
* rimuove il carattere " " che crea problemi con UTF-8
* in questo modo ho il testo del post dopo che i plugin (tipo
* le faccine) hanno applicato le loro modifiche html e ritorno
* il codice html senza entities ma in forma pura
*/
$single = str_replace("&", "&", $buffer);
$spaced = str_replace(" ", " ", $single);
return html_entity_decode($spaced);
}
?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?php echo $title; ?></title>
<link><?php echo $link; ?></link>
<description><![CDATA[<?php echo $description; ?>]]></description>
<language><?php esc_html( bb_option('language') ); ?></language>
<pubDate><?php echo gmdate('D, d M Y H:i:s +0000'); ?></pubDate>
<?php bb_generator( 'rss2' ); ?>
<textInput>
<title><![CDATA[<?php _e('Search'); ?>]]></title>
<description><![CDATA[<?php _e('Search all topics from these forums.'); ?>]]></description>
<name>q</name>
<link><?php bb_uri('search.php'); ?></link>
</textInput>
<atom:link href="<?php echo $link_self; ?>" rel="self" type="application/rss+xml" />
<?php foreach ($posts as $bb_post) : ?>
<item>
<title><?php post_author(); ?> <?php _e('on')?> "<?php topic_title( $bb_post->topic_id ); ?>"</title>
<link><?php post_link(); ?></link>
<pubDate><?php
ob_start("datefix");
bb_post_time('U');
ob_end_flush();
?></pubDate>
<dc:creator><?php post_author(); ?></dc:creator>
<guid isPermaLink="false"><?php post_id(); ?>@<?php bb_uri(); ?></guid>
<description><![CDATA[<?php
ob_start("callback");
post_text();
ob_end_flush();
?>]]></description>
</item>
<?php endforeach; ?>
</channel>
</rss>Sorry for comments in italian.
BTW @ yoyopop, I don’t remember in which topic, but I read on this forum that the problem is related to some plugins having extra spaces in their code before the opening “<?php” tag. Check it…
April 4, 2010 at 11:04 pm #33931Topic: bb-attachments modified nice permalink
in forum PluginspsycheangelsMemberin .htaccess add
RewriteRule ^attachments/([^/]+)/download/([0-9]+)/inline/?$ /?bb_attachments=$1&bbat=$2&inline [L,QSA]
RewriteRule ^attachments/([^/]+)/download/([0-9]+)/?$ /?bb_attachments=$1&bbat=$2 [L,QSA]
in bb-attachments.php line 234 edit like this
if ($attachment->status==0) {
$output.=" "."<a href='".$uri."attachments/$attachment->post_id/download/$attachment->id/'>".$attachment->filename."</a> "." ";
}in bb-attachments.php line 289
if (file_exists($fullpath)) { // it's been resized, so it's likely on AWS, show directly
$aws=$bb_attachments['aws']['url'].$file->id.'.'.$file->filename;
$replace="<a class='bb_attachments_link' href='".$uri."attachments/".$match[1]."/download/".$match[2]."'><img src='$aws' /></a>";
if (is_bb_feed()) {$replace=wp_specialchars($replace);}
$text=str_replace($match[0],$replace,$text);
}in bb-attachments.php line 298
so now your attachments have permalink like this
example.com/attachments/*postid*/download/*attachmentid*/
and embed image url
example.com/attachments/*postid*/download/*attachmentid*/inline/
Related thread : http://bbpress.org/forums/topic/on-attachment-file-permalink
September 5, 2009 at 12:53 am #77508In reply to: All RSS Feeds Broken?
Adam Harley (Kawauso)MemberWith the final patch from track applied against 1.0.2 trunk you get:
bb-templates/kakumei/rss2.php
<?php
header( 'Content-Type: text/xml; charset=UTF-8' );
echo '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "n";
bb_generator( 'comment' );
?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?php echo $title; ?></title>
<link><?php echo $link; ?></link>
<description><?php echo $description; ?></description>
<language><?php esc_html( bb_option('language') ); ?></language>
<pubDate><?php echo gmdate('D, d M Y H:i:s +0000'); ?></pubDate>
<?php bb_generator( 'rss2' ); ?>
<textInput>
<title><![CDATA[<?php _e('Search'); ?>]]></title>
<description><![CDATA[<?php _e('Search all topics from these forums.'); ?>]]></description>
<name>q</name>
<link><?php bb_uri('search.php'); ?></link>
</textInput>
<atom:link href="<?php echo $link_self; ?>" rel="self" type="application/rss+xml" />
<?php foreach ($posts as $bb_post) : ?>
<item>
<title><?php post_author(); ?> <?php _e('on')?> "<?php topic_title( $bb_post->topic_id ); ?>"</title>
<link><?php post_link(); ?></link>
<pubDate><?php bb_post_time('D, d M Y H:i:s +0000', array( 'localize' => false ) ); ?></pubDate>
<dc:creator><?php post_author(); ?></dc:creator>
<guid isPermaLink="false"><?php post_id(); ?>@<?php bb_uri(); ?></guid>
<description><?php post_text(); ?></description>
</item>
<?php endforeach; ?>
</channel>
</rss>bb-includes/defaults.bb-filters.php
<?php
/**
* Sets up the default filters and actions for most
* of the bbPress hooks.
*
* If you need to remove a default hook, this file will
* give you the priority for which to use to remove the
* hook.
*
* Not all of the default hooks are found in this files
*
* @package bbPress
*/
// Strip, trim, kses, special chars for string saves
$filters = array( 'pre_term_name', 'bb_pre_forum_name', 'pre_topic_title' );
foreach ( $filters as $filter ) {
add_filter( $filter, 'strip_tags' );
add_filter( $filter, 'trim' );
add_filter( $filter, 'bb_filter_kses' );
add_filter( $filter, 'esc_html', 30 );
}
// Kses only for textarea saves
$filters = array( 'pre_term_description', 'bb_pre_forum_desc' );
foreach ( $filters as $filter ) {
add_filter( $filter, 'bb_filter_kses' );
}
// Slugs
add_filter( 'pre_term_slug', 'bb_pre_term_slug' );
// DB truncations
add_filter( 'pre_topic_title', 'bb_trim_for_db_150', 9999 );
add_filter( 'bb_pre_forum_name', 'bb_trim_for_db_150', 9999 );
add_filter( 'pre_term_name', 'bb_trim_for_db_55', 9999 );
// Format Strings for Display
$filters = array( 'forum_name', 'topic_title', 'bb_title', 'bb_option_name' );
foreach ( $filters as $filter ) {
add_filter( $filter, 'esc_html' );
}
// Numbers
$filters = array( 'forum_topics', 'forum_posts', 'total_posts', 'total_users', 'total_topics' );
foreach ( $filters as $filter ) {
add_filter( $filter, 'bb_number_format_i18n' );
}
// Offset Times
$filters = array( 'topic_time', 'topic_start_time', 'bb_post_time' );
foreach ( $filters as $filter ) {
add_filter( $filter, 'bb_offset_time', 10, 2 );
}
add_filter('bb_topic_labels', 'bb_closed_label', 10);
add_filter('bb_topic_labels', 'bb_sticky_label', 20);
add_filter('pre_post', 'trim');
add_filter('pre_post', 'bb_encode_bad');
add_filter('pre_post', 'bb_code_trick');
add_filter('pre_post', 'force_balance_tags');
add_filter('pre_post', 'bb_filter_kses', 50);
add_filter('pre_post', 'bb_autop', 60);
add_filter('post_text', 'do_shortcode');
function bb_contextualise_search_post_text()
{
if ( bb_is_search() ) {
add_filter( 'get_post_text', 'bb_post_text_context' );
}
}
add_action( 'bb_init', 'bb_contextualise_search_post_text' );
add_filter('post_text', 'make_clickable');
add_filter('edit_text', 'bb_code_trick_reverse');
add_filter('edit_text', 'wp_specialchars');
add_filter('edit_text', 'trim', 15);
add_filter('pre_sanitize_with_dashes', 'bb_pre_sanitize_with_dashes_utf8', 10, 3 );
add_filter('get_user_link', 'bb_fix_link');
add_filter('sanitize_profile_info', 'esc_html');
add_filter('sanitize_profile_admin', 'esc_html');
add_filter( 'get_recent_user_replies_fields', 'bb_get_recent_user_replies_fields' );
add_filter( 'get_recent_user_replies_group_by', 'bb_get_recent_user_replies_group_by' );
add_filter('sort_tag_heat_map', 'bb_sort_tag_heat_map');
// URLS
if ( !bb_get_option( 'mod_rewrite' ) ) {
add_filter( 'bb_stylesheet_uri', 'esc_attr', 1, 9999 );
add_filter( 'forum_link', 'esc_attr', 1, 9999 );
add_filter( 'bb_forum_posts_rss_link', 'esc_attr', 1, 9999 );
add_filter( 'bb_forum_topics_rss_link', 'esc_attr', 1, 9999 );
add_filter( 'bb_tag_link', 'esc_attr', 1, 9999 );
add_filter( 'tag_rss_link', 'esc_attr', 1, 9999 );
add_filter( 'topic_link', 'esc_attr', 1, 9999 );
add_filter( 'topic_rss_link', 'esc_attr', 1, 9999 );
add_filter( 'post_link', 'esc_attr', 1, 9999 );
add_filter( 'post_anchor_link', 'esc_attr', 1, 9999 );
add_filter( 'user_profile_link', 'esc_attr', 1, 9999 );
add_filter( 'profile_tab_link', 'esc_attr', 1, 9999 );
add_filter( 'favorites_link', 'esc_attr', 1, 9999 );
add_filter( 'view_link', 'esc_attr', 1, 9999 );
}
// Feed Stuff
function bb_filter_feed_content()
{
if ( bb_is_feed() ) {
add_filter( 'bb_title_rss', 'strip_tags');
add_filter( 'bb_title_rss', 'ent2ncr', ;
add_filter( 'bb_title_rss', 'esc_html' );
add_filter( 'bb_description_rss', 'strip_tags');
add_filter( 'bb_description_rss', 'ent2ncr', 8 );
add_filter( 'bb_description_rss', 'esc_html' );
add_filter( 'post_author', 'ent2ncr', 8 );
add_filter( 'post_link', 'esc_html' );
add_filter( 'post_text', 'ent2ncr' );
add_filter( 'post_text', 'htmlspecialchars' ); // encode_bad should not be overruled by esc_html
}
}
add_action( 'bb_init', 'bb_filter_feed_content' );
add_filter( 'init_roles', 'bb_init_roles' );
add_filter( 'map_meta_cap', 'bb_map_meta_cap', 1, 4 );
// Actions
add_action( 'bb_head', 'bb_generator' );
add_action('bb_head', 'bb_template_scripts');
add_action('bb_head', 'wp_print_scripts');
add_action('bb_head', 'wp_print_styles');
add_action('bb_head', 'bb_rsd_link');
add_action('bb_head', 'bb_pingback_link');
if ( $bb_log->type === 'console' ) {
add_action('bb_head', array(&$bb_log, 'console_javascript'));
add_action('bb_admin_head', array(&$bb_log, 'console_javascript'));
}
add_action('bb_send_headers', 'bb_pingback_header');
add_action('bb_admin_print_scripts', 'wp_print_scripts');
add_action('bb_user_has_no_caps', 'bb_give_user_default_role');
add_action('do_pingbacks', array('BB_Pingbacks', 'send_all'), 10, 1);
add_action( 'bb_init', 'bb_register_default_views' );
add_action( 'set_current_user', 'bb_apply_wp_role_map_to_user' );
add_filter( 'bb_pre_get_option_gmt_offset', 'wp_timezone_override_offset' );
unset( $filters, $filter );rss.php
<?php
require('./bb-load.php');
// Determine the type of feed and the id of the object
if ( isset($_GET['view']) || bb_get_path() == 'view' ) {
// View
$feed = 'view';
$feed_id = isset($_GET['view']) ? $_GET['view'] : bb_get_path(2);
} elseif ( isset($_GET['topic']) || bb_get_path() == 'topic' ) {
// Topic
$feed = 'topic';
$topic = get_topic(isset($_GET['topic']) ? $_GET['topic'] : bb_get_path(2));
$feed_id = $topic->topic_id;
} elseif ( isset($_GET['profile']) || bb_get_path() == 'profile' ) {
// Profile
$feed = 'profile';
$feed_id = isset($_GET['profile']) ? $_GET['profile'] : bb_get_path(2);
} elseif ( isset($_GET['tag']) || bb_get_path() == 'tags' ) {
if ( isset($_GET['topics']) || bb_get_path(3) == 'topics' ) {
// Tag recent topics
$feed = 'tag-topics';
} else {
// Tag recent posts
$feed = 'tag-posts';
}
$feed_id = isset($_GET['tag']) ? $_GET['tag'] : bb_get_path(2);
} elseif ( isset($_GET['forum']) || bb_get_path() == 'forum' ) {
if ( isset($_GET['topics']) || bb_get_path(3) == 'topics' ) {
// Forum recent topics
$feed = 'forum-topics';
} else {
// Forum recent posts
$feed = 'forum-posts';
}
$forum = bb_get_forum(isset($_GET['forum']) ? $_GET['forum'] : bb_get_path(2));
$feed_id = $forum->forum_id;
} elseif ( isset($_GET['topics']) || bb_get_path() == 'topics' ) {
// Recent topics
$feed = 'all-topics';
} else {
// Recent posts
$feed = 'all-posts';
}
// Initialise the override variable
$bb_db_override = false;
do_action( 'bb_rss.php_pre_db' );
if ( !$bb_db_override ) {
// Get the posts and the title for the given feed
switch ($feed) {
case 'view':
if ( !isset($bb_views[$feed_id]) )
die();
if ( !$bb_views[$feed_id]['feed'] )
die();
if ( !$topics_object = new BB_Query( 'topic', $bb_views[$feed_id]['query'], "bb_view_$feed_id" ) )
die();
$topics = $topics_object->results;
if ( !$topics || !is_array($topics) )
die();
$posts = array();
foreach ($topics as $topic) {
$posts[] = bb_get_first_post($topic->topic_id);
}
$title = sprintf( __( '%1$s » View: %2$s' ), bb_get_option( 'name' ), $bb_views[$feed_id]['title'] );
$link = get_view_link($feed_id);
$link_self = bb_get_view_rss_link($feed_id);
break;
case 'topic':
if ( !$topic = get_topic ( $feed_id ) )
die();
if ( !$posts = get_thread( $feed_id, 0, 1 ) )
die();
$title = sprintf( __( '%1$s » Topic: %2$s' ), bb_get_option( 'name' ), get_topic_title() );
$link = get_topic_link($feed_id);
$link_self = get_topic_rss_link($feed_id);
break;
case 'profile':
if ( bb_get_option( 'mod_rewrite' ) === 'slugs' ) {
$user = bb_get_user_by_nicename( $feed_id );
} else {
$user = bb_get_user( $feed_id );
}
if ( !$user ) {
die();
}
if ( !$posts = get_user_favorites( $user->ID ) ) {
die();
}
$title = sprintf( __( '%1$s » User Favorites: %2$s' ), bb_get_option( 'name' ), $user->user_nicename );
$link = bb_get_profile_link($feed_id);
$link_self = get_favorites_rss_link($feed_id);
break;
case 'tag-topics':
if ( !$tag = bb_get_tag( $feed_id ) )
die();
if ( !$topics = get_tagged_topics( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) ) )
die();
$posts = array();
foreach ($topics as $topic) {
$posts[] = bb_get_first_post($topic->topic_id);
}
$title = sprintf( __( '%1$s » Tag: %2$s - Recent Topics' ), bb_get_option( 'name' ), bb_get_tag_name() );
$link = bb_get_tag_link($feed_id);
$link_self = bb_get_tag_topics_rss_link($feed_id);
break;
case 'tag-posts':
if ( !$tag = bb_get_tag( $feed_id ) )
die();
if ( !$posts = get_tagged_topic_posts( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) ) )
die();
$title = sprintf( __( '%1$s » Tag: %2$s - Recent Posts' ), bb_get_option( 'name' ), bb_get_tag_name() );
$link = bb_get_tag_link($feed_id);
$link_self = bb_get_tag_posts_rss_link($feed_id);
break;
case 'forum-topics':
if ( !$topics = get_latest_topics( $feed_id ) )
die();
$posts = array();
foreach ($topics as $topic) {
$posts[] = bb_get_first_post($topic->topic_id);
}
$title = sprintf( __( '%1$s » Forum: %2$s - Recent Topics' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) );
$link = get_forum_link($feed_id);
$link_self = bb_get_forum_topics_rss_link($feed_id);
break;
case 'forum-posts':
if ( !$posts = bb_get_latest_forum_posts( $feed_id ) )
die();
$title = sprintf( __( '%1$s » Forum: %2$s - Recent Posts' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) );
$link = get_forum_link($feed_id);
$link_self = bb_get_forum_posts_rss_link($feed_id);
break;
// Get just the first post from the latest topics
case 'all-topics':
if ( !$topics = get_latest_topics() )
die();
$posts = array();
foreach ($topics as $topic) {
$posts[] = bb_get_first_post($topic->topic_id);
}
$title = sprintf( __( '%1$s » Recent Topics' ), bb_get_option( 'name' ) );
$link = bb_get_uri();
$link_self = bb_get_topics_rss_link();
break;
// Get latest posts by default
case 'all-posts':
default:
if ( !$posts = bb_get_latest_posts( 35 ) )
die();
$title = sprintf( __( '%1$s » Recent Posts' ), bb_get_option( 'name' ) );
$link = bb_get_uri();
$link_self = bb_get_posts_rss_link();
break;
}
}
bb_send_304( $posts[0]->post_time );
if (!$description = bb_get_option( 'description' ) ) {
$description = $title;
}
$title = apply_filters( 'bb_title_rss', $title, $feed );
$description = apply_filters( 'bb_description_rss', $description, $feed );
$posts = apply_filters( 'bb_posts_rss', $posts, $feed );
$link_self = apply_filters( 'bb_link_self_rss', $link_self, $feed );
bb_load_template( 'rss2.php', array('bb_db_override', 'title', 'description', 'link', 'link_self'), $feed );
?>September 4, 2009 at 3:17 pm #77507In reply to: All RSS Feeds Broken?
deadlyhifiParticipantThe fix in track wraps CDATA around the title and description, then the »’s work fine and it all validates.
In your theme’s rss2.php replace with this:
<?php
header( 'Content-Type: text/xml; charset=UTF-8' );
echo '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "n";
bb_generator( 'comment' );
?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?php echo $title; ?></title>
<link><?php echo $link; ?></link>
<description><![CDATA[<?php echo $description; ?>]]></description>
<language><?php esc_html( bb_option('language') ); ?></language>
<pubDate><?php echo gmdate('D, d M Y H:i:s +0000'); ?></pubDate>
<?php bb_generator( 'rss2' ); ?>
<textInput>
<title><![CDATA[<?php _e('Search'); ?>]]></title>
<description><![CDATA[<?php _e('Search all topics from these forums.'); ?>]]></description>
<name>q</name>
<link><?php bb_uri('search.php'); ?></link>
</textInput>
<atom:link href="<?php echo $link_self; ?>" rel="self" type="application/rss+xml" />
<?php foreach ($posts as $bb_post) : ?>
<item>
<title><?php post_author(); ?> <?php _e('on')?> "<?php topic_title( $bb_post->topic_id ); ?>"</title>
<link><?php post_link(); ?></link>
<pubDate><?php bb_post_time('D, d M Y H:i:s +0000', array( 'localize' => false ) ); ?></pubDate>
<dc:creator><?php post_author(); ?></dc:creator>
<guid isPermaLink="false"><?php post_id(); ?>@<?php bb_uri(); ?></guid>
<description><?php post_text(); ?></description>
</item>
<?php endforeach; ?>
</channel>
</rss> -
AuthorSearch Results