Category Archives: Wordpress Customization

Unable to update some wordpress users

One of my clients had this issue – unable to update some of the wordpress users. When trying to update some of the user, he was getting this error
Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string in C:\web\wp28\wp\wp-includes\functions.php on line 1463

I went through many fixes, suggested in different threads, to edit the wordpress core file wp-includes\functions.php. None of them worked.

Since it only affects certain users I figured out that, the error may be because of the details of that particular user. I checked the database. I have seen some user meta keys related to a plugin which is uninstalled improperly. I deleted those meta keys and the error has gone away…

Is this a bug in Thesis theme?

In thesis theme, when we use teasers, we have the link “Read Full article”.

But they have the nofollow tag.

Is this a bug in the theme?  nofollow means Google and other search engines won’t follow the link.

The home page won’t losss the page rank, but will the posts be indexed by Google?

The same issue is there with comments also. They also have nofollow tags.

We can remove them by editing the files, but I was just wondering why Thesis is forcing this nofollow tag to teasers and comments…

Update on Aug: 28th

Oh it can’t be considered as a bug. Because the post titles have follow tag. In that case “no follow ” for “Read Full Article” is good for SEO.

Compare title and category name in wordpress

I had come through a situation to compare the category name and post title for a wordpress post. The following functions and code helped me to do this.

$category = get_the_category();
$cat = $category[0]->cat_name;
$post_no = get_post($post);
$title = $post_no->post_title;
$match=strcmp($cat,$title);
if($match==0){
echo “match”;
}
else
{
echo “no match”;
}

The problem here is $cat = $category[0]->cat_name; returns the first category name, so we are comparing only the first category with the title. If we want to compare the second category we have to use $cat = $category[1]->cat_name;

I hope someone will write a better solution so that we can compare the array, category with title. I would appreciate if someone can post that…

in_array came to my mind, but it is case sensitive…

Blank page for wp-admin

Just now, I had been in a horrible situation that I can see all my blog pages but when I go to http://worth2read.org/blog/wp-admin/ it appears as blank. That is I am completly locked out of the admin area.

I made a Google search for the solution and confused with lots of solutions that appeared.

However atlast I manged to get my admin page back, the solution that worked for me is as follows…

I checked the functions.php in my theme folder. There were some spaces at the top and bottom of the page. i deleted it.

I got my admin page back so that I can post this for you now.

I am posting it here thinking if anyone else came through such situation, it will be helpful for them.

Adding new widgets in wordpress themes

We can add new widgets by using functions.php in the theme folder.

For example I can add “Services I offer and Google Adsense in 2 ways
to the sidebars.

1. Code both to the page sidebar.php
3. Create widgets using functions.php file in the theme folder

Following code shows how I added a simple Adsense widget using functions.php

if (function_exists(‘register_sidebar’))
{
register_sidebar_widget(__(‘Adsense’), ‘google_widget’);
}

function google_widget() {
echo $before_widget;
echo $before_title;

echo”<li><h2>Sponsors</h2></li>”;
echo $after_title; 
?>
 <ul>
 <li>

Here comes Adsense code

</li>
 </ul>
 <?php echo $after_widget; 
}

function init_adsense(){
    register_adsense_widget(“Sponsors”, “google_widget”);    
}

add_action(“plugins_loaded”, “init_adsense”);

The above code gives a simple widget named adsense in the widget panel. From the widget list I can add it to the sidebar without disturbing sidebar.php file.

Update:

Just now, I  noticed another method,  if the widget contains text or HTML only. In such cases you can use text widgets. Add the already existing “Text widget”.

In the example above give the title as “Sponsors” and write adsense code in the box. It is the easiest way if the widget you are making contains only text or HTML.

Adding Separate boxes for wordpress excerpts

In most of the themes the post container lists all the excerpts of the most recent posts in the home page. The following code will help you to break up each post into separate boxes.

Example: Theme Home page Preview

Using css we can make a 10px gap in-between each post, where the background of the page shows through.

In the page index.php we have

————————————-

<div id=”content”>

<?php while (have_posts()) : the_post(); ?>

   <div class=”post” id=”post-<?php the_ID(); ?>”>

 <div class=”title-bg”>   <h2 class=”title”>

<a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></a>

</h2></div>
 <div class=”entry”>

     <?php the_excerpt(); ?>

     <p class=”links”>

<a href=”<?php the_permalink() ?>” class=”more”>&laquo;&laquo;&nbsp;&nbsp;Read More</a></p>

    </div>   </div>

  <?php endwhile; ?>

——————————————–

I was just copying the index page. Ignore the div tags you don’t want , but the following css code for content and post will help to add a separation between each post.

—————————–

#content {

float: left;

width: 600px;

border-left: 1px #BBBBBB dashed;

margin-left:10px;

}

.post {

padding-bottom: 15px;

line-height: 200%;

background-color:#FFFFCC;

margin-top:10px;

}

——————–

Here “background-color:#FFFFCC;” gives an yellow background and “margin-top:10px;” gives a gap with the background color mentioned in #content background color.

In this example it is white.

Import From B2evolution(2.4.6) to WordPress (2.7)

The outdated version of migrate.php is already available. I had just updated it so that we can use it for the latest version. Only some field names, table names etc are changed.

Step 1: Upload the wordpress files to the b2evolution directory (This is to keep permanent link as same)

Step2: Install wordpress, Use the same database as that of b2evolution.

Step3: Upload the script migrate.php to the folder wp-admin . Run migrate.php

Help with Permanent Link

The table wp_options contains a field, “permalink_structure” edit it and keep it in the way you want.

Some notes about the script : migrate.php

================================================
Step1 :  You have to connect to the database.

Step2:  Remove the present contents of wordpress tables. It is better not to delete details of user. Otherwise wordpress admin may not be able to access the admin area after running the script.

Step3:  Import users and user meta data.

The table evo_users contains users of your present blog. Select it from evo_users and insert it into wp_users.

Step4:  Import categories.

The table evo_categories contains the category name. Import them to wp_terms.

WordPress handles categories using wp_terms and wp_term_taxonomy tables

Step5: Import the posts

The table evo_items__item contains the posts . Import them to wp_posts.

Step6: Establish category-Post relation.

The table evo_postcats contains the relation between posts and categories. We can import them to wp_term_relationship

This is the difficult part of the job, since wordpress handles category using 3 tables wp_terms, wp_term_taxonomy and wp_term_relationships.

Step6: Process the category counts, ie here we are counting how many posts per category

Step7: Import coments

We have to  import comments from evo_comments to wp_comments

In this way we can import posts, comments, categories, category-post relationship. We can settle permanent link issue by editing wp_options table.

Update on May 17th 2009:
One of the clients asked whether I can fix tags and authors. I have updated the script to import tags and authors.
So now the script will import posts, comments, categories, category-post relationship, tags tag-post relationships and authors. We can settle permanent link issue by editing wp_options table and .htaccess file.

For the script, migrate.php , please contact gsh [dot] james [at] gmail [dot] com .  We will be happy to assist in importing your b2evolution blog to wordpress. [Paid Service]

Price for assistance : 50 – 75 USD ( depending on the data that need to be exported )

Linkedin profile: http://www.linkedin.com/in/gishajames

Thanks