Skip to content

Posts from the ‘WordPress MU’ Category

21
May

WordPress 3.0 Custom Post Type Custom Fields

I have been trying out the custom post types for WordPress 3.0 Beta 2, I ran into a problem where i could not call the custom fields for posts i have assigned custom post type values.

I came up with this workaround for now until it is sorted.

function get_post_meta_custom($key, $single = false) {
 global $wpdb,$post;
 $answer = $wpdb->get_var($wpdb->prepare("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = ".$post->ID." AND meta_key = '".$key."'"));
 return $answer;
}

Call it using the following. I use this inside on the single post inside the loop.

 if ( get_post_meta_custom('client_name', true) ) {echo get_post_meta_portfolio('client_name', true);    }

Popularity: 1% [?]

30
Apr

FeedMyMedia WPMU Recent Posts

Recent posts are great, but on a WPMU install you sometimes want to pull through blog posts from a specific sub-blog. Attached to this post is just that. A widget that will allow you to set what blog you want to pull from based on its id, how many posts you want to pull, and lastly set a title.

This is just a skeleton, you can always add in calls to custom fields and other amazing goodies.

NB Not for commercial USE

Download: fmm-wpmu-recent-posts (rename to .php)

Download: fmm-wpmu-recent-posts v1.1 (rename to .php)

Popularity: 2% [?]

3
Mar

Disable your BuddyBar

Somtimes you do not want the buddybar to display on your site. You can hide it with css but WordPress will still process all the info for it.

Add the following line to your functions.php file to disable the BuddyBar

define ('BP_DISABLE_ADMIN_BAR', false);

Popularity: 2% [?]

17
Feb

Define you BuddyPress Slugs

Add these lines of code to your wp-config.php file to rename the slugs of the buddypress components ( these are for the members slug and the groups slug )

define( 'BP_GROUPS_SLUG', 'companies' );
define( 'BP_MEMBERS_SLUG', 'volunteers' );

Popularity: 2% [?]

19
Jan

WordPress/BuddyPress – Meta title tag not working

If your buddypress child theme or customized parent theme does not work properly, in otherwords does you title tag output “[Blogname] – Blog” then use the code below to remedy the error.

Whats happening is if you use bp_title_tag() is will output the default string as seen above. If you lean towards using the WordPress conditional tags to test the pages, WordPress will see the BuddyPress pages as normal static pages.

Using bp_get_title_tag we can test to see if its a WordPress page or a BuddyPress page and use the appropriate title tag.

<title><?php
if ( is_home() ) { bloginfo('name'); echo '&nbsp;|&nbsp;'; bloginfo('description'); }
elseif ( is_search() ) { bloginfo('name'); echo '&nbsp;|&nbsp;'; _e('Search Results'); }
elseif ( is_author() ) { bloginfo('name'); echo '&nbsp;|&nbsp;'; _e('Author Archives'); }
elseif ( is_single() ) { bloginfo('name'); echo '&nbsp;|&nbsp;'; wp_title(''); } 

// Entering the buddypress tags
elseif ( is_page() ) { 

 $page_title = rtrim(ltrim(bp_get_page_title()));

 if ( $page_title == "[INSETRT YOUR WP_TITLE HERE] &#8212; Blog" ) { bloginfo('name'); echo '&nbsp;|&nbsp;'; wp_title('');}
 else{ bp_page_title(); }
}
elseif ( is_category() ) { bloginfo('name'); echo '&nbsp;|&nbsp;'; _e('Archive'); echo '&nbsp;|&nbsp;'; single_cat_title(); }
elseif ( is_month() ) {  bloginfo('name'); echo '&nbsp;|&nbsp;'; _e('Archive'); echo '&nbsp;|&nbsp;'; the_time('F'); }
elseif (function_exists('is_tag')) { if ( is_tag() ) { bloginfo('name'); echo '&nbsp;|&nbsp;'; _e('Tag Archive'); echo '&nbsp;|&nbsp;';  single_tag_title("", true); } }
else {  } ?></title>

Popularity: 10% [?]

10
Nov

WordPress Resources

Just got two useful links in my mail today

WordPRess 2.8 Cheat Sheet – All the useful template tags and functional reference you need for developing in WordPress 2.8

WPMU SPLOG Removal - Removing all of the nasty spam blogs and how to prevent them on your site.

Popularity: 1% [?]

7
Oct

Conversion Thank You page for BuddyPress Registration

I recently had to create a second step “Thank you” page for a client so they could add their Conversion Tracking code to it. Most people will simply add the tracking code to the registration page and set the URLs in your Conversion Tracking software.

Some tracking software programs have trouble when it comes to using the same url for the start and the conversion goal.  Here’s what i did to create a “Thank You” page.

  • Open up your theme folder and copy the register.php template
  • Rename it to thank-you.php (or anything you want really)
  • Next open up thank-you.php and paste the following into it right at the top (line 1) to create a static page template.
<?php /* Template Name: Thank You Template*/ ?>
  • Log into your backend and create a static page called “Thank-you” and select the “Thank Your Template” from the list.
  • Next open up the register.php and insert the following line straight after the call for the register form. This uses javascript to change the action of the form to send to the thank-you page.
<script type="text/javascript"> var changer = document.getElementById('setupform'); changer.action = 'http://yoursite.org.za/thank-you';</script>
  • Lastly to make sure no one visits this page except during the registration process add the following lines of code just below the <body> tag

I have attached the two file register.php and thank-you.php so you can see how i did it.

Popularity: 2% [?]

5
Oct

Running quick tags outside of the loop

For anyone who has had the same frustration I have where you need tocall a function from a plugin, but they only have a quick tag you insert into the post/page.

Solution

<?php echo apply_filters(“the_content”,”[Insert Your Quick Tag Here]“); ?>

This will apply the filter that is usually applied when a post is queried, and display the quick tag as it would normall if you inserted via the backend.

Popularity: 2% [?]

1
Oct

Disable all caching on specific pages

Copy and paste this code into the template you want to disable caching on, usually used on activation pages
if( is_object( $wp_object_cache ) )
	   $wp_object_cache->cache_enabled = false;

Popularity: 1% [?]