How can you create a loop to get posts/pages from different blogs under same MU installation?
1) you can use switch_to_blog function
http://codex.wordpress.org/WPMU_Functions/switch_to_blog
2) create wordpress loop (this will get posts from the blog you just switched)
3) do whatever you want with data
4) restore current blog you are on so everything runs after this code go to the blog it supposed to
http://codex.wordpress.org/WPMU_Functions/restore_current_blog
switch_to_blog(1); // we are switching to blog id # 1
query_posts('showposts=5'); //this would get top 5 posts from blog id # 1. you can change the loop to the get posts from x category
if (have_posts()) :
while (have_posts()) : the_post();
//do whatever you want with data here...
endwhile;
endif;
restore_current_blog();
Tags: Posts/Pages from different blogs, Wordpress Loop, wordpress-mu
Posted in Wordpress | No Comments »
No Comments | December 11th, 2009 | by Jaymin Patel
Very nice presentation @ Wordcamp NYC this year on Wordpress Security.
Slides: http://www.slideshare.net/williamsba/wordpress-security-updated
Video on Vimeo: http://www.vimeo.com/7685380
Also upgrade your blog as soon as new version comes out.
Can we say now “Hack it if you can!”?
Tags: securing-wordpress, Wordpress
Posted in Wordpress | No Comments »
No Comments | December 8th, 2009 | by Jaymin Patel
Posted in KAPISH | No Comments »
No Comments | November 3rd, 2009 | by Jaymin Patel
I was upgrading mu site to 2.8.4. I went to Site Admin -> Upgrade and hit Upgrade Site button. It worked for first 25 – 30 blogs and then died with message
Warning! Problem upgrading . Your server may not be able to connect to blogs running on it.
Error message: 200: Operation timed out after 3 seconds with 0 bytes received
This is what I did to fix my problem
I opened wp-admin/wpmu-upgrade-site.php and wp-includes/http.php
function &_getTransport( $args = array() ) {
on line number 94 of wp-includes/http.php, wordpress tests different http request methods exist on your server during upgrade.
1st test was the culprit on my server which uses http_request method built into PHP. I guess this method was taking long time to resolve DNS and so it was timing out.
if ( true === WP_Http_ExtHttp::test($args) ) {
$working_transport['exthttp'] = new WP_Http_ExtHttp();
$blocking_transport[] = &$working_transport['exthttp'];
}
I did comment out this test and let Wordpress start with next one.
if ( true === WP_Http_Curl::test($args) ) {
$working_transport['curl'] = new WP_Http_Curl();
$blocking_transport[] = &$working_transport['curl'];
}
And guess what? All 150 blogs were updated in a few minutes without any problem.
If even curl does not work for you, you can comment it out and move on to the next until WP upgrade site works for you.
Good Luck!
Tags: Wordpress, Wordpress MU 2.8.4, Wordpress MU 2.8.4a, Wordpress MU Site Upgrade, wordpress-mu
Posted in KAPISH, Wordpress | 1 Comment »
1 Comment | October 8th, 2009 | by Jaymin Patel
$fontSizeUnits = "px";
$fontSizeMin = 15;
$fontSizeMax = 50;
$maxValue = 12;
$minValue = 1;
where $results is MySQL result set.
foreach ($results as $result) {
$tag = $result->name;
$tagURI = get_option('home') . '/' . $result->taxonomy . '/' . $result->slug . '/';
$count = $result->count;
$weight = ( $count - $minValue ) / ( $maxValue - $minValue );
$fontSize = $fontSizeMin + round( ($fontSizeMax - $fontSizeMin) * $weight );
echo "<li style='display: inline-block; font-size:". $fontSize. $fontSizeUnits."'><a href=".$tagURI." title='(".$count." posts)'>".$tag."</a></li>";
}
Tags: Tag Cloud
Posted in KAPISH, Wordpress | No Comments »
No Comments | August 25th, 2009 | by Jaymin Patel
This solution will work for you if you want your child theme have fewer templates and if any template is missing, it should not break your blog but should go to parent theme and load it.
And a few important things to set,
1) parent theme folder name
2) child theme folder name
3) Template set in child theme style.css must match parent theme folder name
Because child theme name and Template set in child theme style.css are stored in options table.
read more »
Tags: inherited themes, parent child themes, Wordpress, Wordpress MU 2.6.5, wordpress parent child theme
Posted in PHP, Wordpress | No Comments »
No Comments | August 7th, 2009 | by Jaymin Patel
There are a few ideas out there How to build date archive for a category. I am joining the race now.
Some of us, wordpress developers, may think this is hacky but I bet a few will like it this way because this works!.
read more »
Tags: Date archive for a category, wordpress archives for category, wordpress-category-date-archive
Posted in KAPISH | 10 Comments »
10 Comments | June 16th, 2009 | by Jaymin Patel
If you want to encode/decode JSON within/using wordpress, you can take a look at
/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php
This file has Moxiecode_JSON class which can do that for you.
read more »
Tags: decode-json-wordpress, encode-json-wordpress, json-wordpress, wo, Wordpress
Posted in KAPISH | 3 Comments »
3 Comments | March 17th, 2009 | by Jaymin Patel
Hi Everyone. I’m back in the business!
I decided I will write about my trip the same day I was landed in USA but I was caught up checking 1,000 emails and work load.
It’s always great going back home and meeting your people. I enjoyed a lot this time in India. Hanging out with friends, family regroup, my grandmother and a lot! This year I relaxed a bit as well and some days were so busy. Kite Fastival, Uttarayana or Makarsakranti was too good. I fly kites after 2 years.
read more »
Tags: india trip, kite fastival, makarsakranti
Posted in India, KAPISH, USA, Vacation | No Comments »
No Comments | February 4th, 2009 | by Jaymin Patel
I have been googling for this and again come up with my own solution.
function my_set_gmt_offset($offset) {
$timezone = date("T");
if($timezone == 'EDT') {
$offset = '-4';
}
else if($timezone == 'EST') {
$offset = '-5';
}
return $offset;
}
if(function_exists('add_filter')) {
add_filter('option_gmt_offset', 'my_set_gmt_offset');
}
Share your feedback via comments.
Tags: daylight saving time, daylight saving time and wordpress, daylight saving time wordpress plugin, wordpress and daylight saving time, wordpress timezone settings
Posted in KAPISH, Wordpress | 1 Comment »
1 Comment | November 12th, 2008 | by Jaymin Patel