Top

Daily Tip: How to Exclude a Group From the Loop in BuddyPress

July 2, 2010

One sure fire way to exclude groups from the loop in BuddyPress is to set them as Private or Hidden in the admin settings. However, if you need the group to be visible in the directory but not in a particular widget, then you’ll have to use a little hack for now.

One example would be if you’re using a group as a shell for a “global forum” and you want to exclude that group from a widget that displays popular groups. BuddyPress documentation for custom group loops doesn’t include a parameter for excluding particular groups, so here’s how you can do it:

<?php while ( bp_groups() ) : bp_the_group();  if(bp_get_group_name() != 'My Group' ) : ?>

Replace ‘My Group’ with the group name that you want to exclude. Also, don’t forget to add an endif; right before the endwhile;

<?php endif; ?>

Many thanks to nahummadrid and r-a-y at the BuddyPress forums for this quick hack.

Tweet This Post


BuddyPress Hack to Add a Syntax Highlighter to Group Forums

July 2, 2010

Have you been wishing for an easy way to add syntax highlighting to your BuddyPress group forums? Now you can and it will only take you three minutes to hook it up. This hack was posted in the BuddyPress support forums by Rich Fuller, a prolific BuddyPress hacker and plugin developer whose blog is definitely subscription worthy. You can also see a live demo on his website.

How to Add a Syntax Highlighter to BuddyPress Group Forums

Step 1: Download SyntaxHighlighter Evolved

Install this plugin as you normally would. You’ll notice that it will only work for posts and pages. There’s just one more step to get it working with BuddyPress. Also, you need to be using BuddyPress version 1.2.4.1 or higher for this to work.

Add the Filters to syntaxhighlighter.php

add_filter( 'bp_get_the_topic_post_content', array(&$this, 'parse_shortcodes'), 7 );
add_filter( 'group_forum_post_text_before_save', array(&$this, 'encode_shortcode_contents_slashed'), 1 );
add_filter( 'group_forum_topic_text_before_save', array(&$this, 'encode_shortcode_contents_slashed'), 1 );
add_filter( 'bp_get_the_topic_text', array(&$this, 'decode_shortcode_contents'), 1 );
add_filter( 'bp_get_the_topic_post_edit_text', array(&$this, 'decode_shortcode_contents'), 1 );

You should add these statements in the file right after you see this:

add_filter( 'the_content', array(&$this, 'parse_shortcodes'), 7 );

Re-upload the file and now you’ll find that you can post code much more easily in the forums.

Now… if we could only get this added to the support forums at BuddyPress.org. ;) Here are five reasons why it’s a good idea to add a syntax highlighter at the BuddyPress forums or any other developer-centric site for that matter:

  1. Adding a syntax highlighter will eliminate a lot of errors people have with copying and pasting format issues.
  2. Developers will enjoy helping others more.
  3. It will significantly improve readability in the forums.
  4. It will make the forums more user-friendly and efficient so that people can find help faster.
  5. People will love it!

Feel free to add to this list in the comments below. :)

Tweet This Post


Daily Tip: How to Embed RSS Feed Entries in WordPress Posts

July 1, 2010

If you want to list some of the latest posts from another site within one of your WordPress posts or pages, here’s a handy way to do it using a shortcode. First, add this to your functions.php file:

//This file is needed to be able to use the wp_rss() function.
>include_once(ABSPATH.WPINC.'/rss.php');
function readRss($atts) {
    extract(shortcode_atts(array(
	"feed" => 'http://',
      "num" => '1',
    ), $atts));
    return wp_rss($feed, $num);
}
add_shortcode('rss', 'readRss');

After adding that you can now use a shortcode to embed RSS:

[rss feed="http://wpmu.org/feed" num="5"]

It will look a little something like this:

Source: CatsWhoCode.com

Tweet This Post


Guide to Making Your WordPress Posts and Pages Print-Friendly

July 1, 2010

Having a “Print Page” button is especially important for WordPress sites used for education, course management, online magazines, project management, news sources, or any other informational site. The ability to easily print pages can have a significant impact on your reader’s experience with your website.

How frustrating is it to want to print a page from a site that has no print view? You either have to print a full page of ink or copy the relevant text into a document and print from there. This is very inconvenient and does nothing to promote your brand.

How to Add a Print Page Button to Your WordPress Theme

If you have a fairly minimalistic theme design and simply want to add a “Print Page” button to your posts or pages, just drop this snippet anywhere you want in your template files:

<script language="JavaScript">
  if (window.print) {
  document.write('<form> '
  + '<input type=button name=print value="Print Page" '
  + 'onClick="javascript:window.print()"></form>');
  }
</script>

Source: WP Special

However, if you really want to improve your user’s experience, you may want to add in a few more features than just the button to launch the printer. You can, of course, add print styles to your theme’s stylesheet, but this can get very tedious. If you want an easier way to accomplish this, skip to the plugin option below.

Plugin Option for Adding a Print Button to Posts and Pages

WP-Print

WP-Print will enable you to add a “Print This Page” button to your posts and pages with a small icon and a number of dashboard options: edit the print text link, select an icon, and decide wither or not you want to print individual items, such as comments, links, images, videos and a custom copyright text. When you click on the print button, you’ll be redirected to a print-friendly version of your post or page.

If you want to further customize how your print pages look, you can edit the print-css.css file included with the plugin. Change the text color, add a logo, change the width, and brand it for your site.

If you’re having trouble getting the print button to show up using the WordPress 3.0 2010 theme, you can add its template tag to the single.php or page.php:

<?php if(function_exists('wp_print')) { print_link(); } ?>

Adding easy printing capabilities may not be necessary for every site, but it certainly adds a touch of professionalism. Content printed from your website goes places that your site cannot go. Give your online presence some legs with a well-designed print page.

Tweet This Post


Bottom
Article Archive  |  This site is a historical archive of pressography.com, a WordPress plugin and theme blog that published between 2006 and 2012. It is preserved for reference and is not operated by, affiliated with, or endorsed by its original authors. Nothing here is for sale and no form on this site is active. If you are the original owner and would like this domain returned, please get in touch.