Archive for the ‘WordPress KB’ Category
Posted by Shane on March 8, 2010 1:03 pm
Hi,
Problem Error:
Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /your-sitepath/wp-includes/category-template.php on line 176
Possible Solution:
- This problems stems from line 176 as stated above. The simple fix is to make sure the first argument is a string, to do this we will rap it in double quotes.
Change line 176 from:
if(array_key_exists($category, $categories))
To
if(array_key_exists(‘$category’, $categories))
Just add single quotes around the first $category variable which will fixed the issue.
Thanks,
Shane G.
Popularity: 1%
Posted by Shane on March 5, 2010 12:54 pm
Hi,
Problem Summary:
I have upgraded wordpress version to the latest along with plugins. I have encountered this error message on my blog as well as while trying to login into the admin area of the blog:
Fatal error: Call to undefined function: str_split() in /home/…/htdocs/wp-content/plugins/pods/init.php on line 27
Possible Solution:
- str_split is a PHP 5 function. It seems that your site/blog is running on PHP4 version. Hence, upgrade your domain/blog PHP version to PHP5 with the help of your hosting service provider. Once you upgrade it, your problem should be resolved positively.
Thanks,
Shane G.
Popularity: 1%
Posted by Shane on December 11, 2009 2:32 am
Hi,
In order change the background image of your blog, you need to upload the image in image folder of your theme. Image must be the same pixel as the old image. Othewise it may wrap the page.
Image folder path: blog-directory/wp-content/themes/theme-folder/images
Image name should be; bg.jpg
Thanks,
Shane G.
Popularity: 1%
Posted by Shane on 1:54 am
Hi,
Many wordpress users likes the theme but wants to change the sidebar angle from left to right and visa versa. I have described here how to switch the sidebar in wordpress theme. I have provided details here to move sidebar from left to right.
In order to change the sidebar angle, you need to edit the style.css file of the theme. Open style.css file of your theme to edit it.
Search This Code:
.narrowcolumn
{
float: left;
padding: 0 0 20px 45px;
margin: 0px 0 0;
width: 450px;
}
Replace above code with this code;
.narrowcolumn
{
float: right;
padding: 0 45px 20px 0px;
margin: 0px 0 0;
width: 450px;
}
Now, search this code;
#sidebar
{
padding: 20px 0 10px 0;
margin-left: 545px;
width: 190px;
}
Replace with this code:
#sidebar
{
padding: 20px 0 10px 0;
margin-left: 20px;
width: 190px;
}
You can set the margin accoring to your requirement. Now, save this file and upload to your theme folder.
In order to change the sidebar from right left. Need to do the reverse process.
That’s it!
Thanks,
Shane G.
Popularity: 1%
Posted by Shane on December 4, 2009 6:35 pm
Hi,
These are the documentation – guidelines for wordpress theme development:
1. Indicate precisely what your Theme and template files will achieve.
2. Adhere to the naming conventions of the standard theme hierarchy.
3. Indicate deficiencies in your Themes, if any.
4. Clearly reference any special modifications in comments within the template and style sheet files. Add comments to modifications, template sections, and CSS styles, especially those which cross template files.
5. If you have any special requirements, which may include custom Rewrite Rules, or the use of some additional, special templates, images or files, please explicitly state the steps of action a user should take to get your Theme working.
6. Try and test your Theme across browsers to catch at least a few of the problems the users of the Theme may find later.
7. Provide contact information (web page or email), if possible, for support information and questions.
A README file included with your Theme helps many users over any potential stumbling blocks.
Thanks,
Shane G.
Popularity: 1%
Posted by Shane on October 23, 2009 8:01 am
Hi,
Wordpress 2.8+ has new feature of the_modified_author() which allows you to display the latest who has modified the post. In order to display the modified post author you can use this hack and add this code in functions.php file:
if (!function_exists(‘get_the_modified_author’)) {
function get_the_modified_author() {
global $post;
if ( $last_id = get_post_meta($post->ID, ‘_edit_last’, true) ) {
$last_user = get_userdata($last_id);
return apply_filters(‘the_modified_author’, $last_user->display_name);
}
}
}
if (!function_exists(‘the_modified_author’)) {
function the_modified_author() {
echo get_the_modified_author();
}
}
Once you have updated the functions.php file, you can use this code to display the last modified post author details:
<?php the_modified_author(); ?>
That’s it!
Thanks,
Shane G.
Popularity: 1%
Posted by Shane on 7:52 am
Hi,
Many wordpress theme is not supported perfectly in many web browsers. In order to detect the visitors’ web browser, you can use this hack. For that you need to add this code in functions.php file of your theme:
<?php
add_filter(‘body_class’,'browser_body_class’);
function browser_body_class($classes) {
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
if($is_lynx) $classes[] = ‘lynx’;
elseif($is_gecko) $classes[] = ‘gecko’;
elseif($is_opera) $classes[] = ‘opera’;
elseif($is_NS4) $classes[] = ‘ns4′;
elseif($is_safari) $classes[] = ’safari’;
elseif($is_chrome) $classes[] = ‘chrome’;
elseif($is_IE) $classes[] = ‘ie’;
else $classes[] = ‘unknown’;
if($is_iphone) $classes[] = ‘iphone’;
return $classes;
}
?>
Once you update the functions.php the function will automatically add a CSS class to the body tag. Here is one example:
<body>
Now, you need to define the stylesheet according to the browser in style.css
That’s it!
Thanks,
Shane G.
Popularity: 1%
Posted by Shane on 2:34 am
Hi,
Tag Cloud may be not diosplay properly. In order to over come from that situation, you can use this hack to display tags in drop down menu. For that you need to add this code in functions.php file of your blog:
<?php
function dropdown_tag_cloud( $args = ” ) {
$defaults = array(
’smallest’ => 8, ‘largest’ => 22, ‘unit’ => ‘pt’, ‘number’ => 45,
‘format’ => ‘flat’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’,
‘exclude’ => ”, ‘include’ => ”
);
$args = wp_parse_args( $args, $defaults );
$tags = get_tags( array_merge($args, array(‘orderby’ => ‘count’, ‘order’ => ‘DESC’)) ); // Always query top tags
if ( empty($tags) )
return;
$return = dropdown_generate_tag_cloud( $tags, $args ); // Here’s where those top tags get sorted according to $args
if ( is_wp_error( $return ) )
return false;
else
echo apply_filters( ‘dropdown_tag_cloud’, $return, $args );
}
function dropdown_generate_tag_cloud( $tags, $args = ” ) {
global $wp_rewrite;
$defaults = array(
’smallest’ => 8, ‘largest’ => 22, ‘unit’ => ‘pt’, ‘number’ => 45,
‘format’ => ‘flat’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’
);
$args = wp_parse_args( $args, $defaults );
extract($args);
if ( !$tags )
return;
$counts = $tag_links = array();
foreach ( (array) $tags as $tag ) {
$counts[$tag->name] = $tag->count;
$tag_links[$tag->name] = get_tag_link( $tag->term_id );
if ( is_wp_error( $tag_links[$tag->name] ) )
return $tag_links[$tag->name];
$tag_ids[$tag->name] = $tag->term_id;
}
$min_count = min($counts);
$spread = max($counts) – $min_count;
if ( $spread <= 0 )
$spread = 1;
$font_spread = $largest – $smallest;
if ( $font_spread <= 0 )
$font_spread = 1;
$font_step = $font_spread / $spread;
// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
if ( ‘name’ == $orderby )
uksort($counts, ’strnatcasecmp’);
else
asort($counts);
if ( ‘DESC’ == $order )
$counts = array_reverse( $counts, true );
$a = array();
$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ‘ rel=”tag”‘ : ”;
foreach ( $counts as $tag => $count ) {
$tag_id = $tag_ids[$tag];
$tag_link = clean_url($tag_links[$tag]);
$tag = str_replace(‘ ‘, ‘ ’, wp_specialchars( $tag ));
$a[] = “\t<option value=’$tag_link’>$tag ($count)</option>”;
}
switch ( $format ) :
case ‘array’ :
$return =& $a;
break;
case ‘list’ :
$return = “<ul class=’wp-tag-cloud’>\n\t<li>”;
$return .= join(“</li>\n\t<li>”, $a);
$return .= “</li>\n</ul>\n”;
break;
default :
$return = join(“\n”, $a);
break;
endswitch;
return apply_filters( ‘dropdown_generate_tag_cloud’, $return, $tags, $args );
}
?>
You can use this function to display dropdown menu of tags. Just open the file where you want the list to be displayed like sidebar.php and paste this code:
<select name=”tag-dropdown” onchange=”document.location.href=this.options[this.selectedIndex].value;”>
<option value=”#”>Liste d’auteurs</option>
<?php dropdown_tag_cloud(‘number=0&order=asc’); ?>
</select>
That’s it!
Thanks,
Shane G.
Popularity: 1%
Posted by Shane on 2:06 am
Hi,
Many wordpress users wants to add special character in their menu list. Wp_list_pages is very useful function of wordpress to display the pages in menu. Whenever you would like to add special character ike ‘|’, ‘//’ etc.., you can use this hack. You need to add this code where you want to add the special character:
special_charater code
For example, I have used pipe sign as special character. You can use as per your requirement.
That’s it!
Thanks,
Shane G.
Popularity: 1%
Posted by Shane on October 19, 2009 2:44 am
Hi,
When a new version of Wordpress is available, update now Wordpress message is displayed on your dashboard. It is always better so that you can identify the latest released version and upgrade the installed. But many wordpress users wants to disable this message on their dashboard. For that you need to add this code in functions.php file of your theme:
if ( !current_user_can( ‘edit_users’ ) )
{
add_action( ‘init’, create_function( ‘$a’, “remove_action( ‘init’, ‘wp_version_check’ );” ), 2 );
add_filter( ‘pre_option_update_core’, create_function( ‘$a’, “return null;” ) );
}
That’s it!
Thanks,
Shane G.
Popularity: 1%