Skills on How to Show different Adsense Ads at WordPress

More and more people love to use wordpress to setup blogs and place adsense ads, and many people still love the use the theme of Classic, by Dave Shea. Can we show different adsense code at the same place, but different pages then? For example, we want to show 2 adsense block at the main body of detailed pages, but only show 1 adsense block at other page’s main body.
Continue reading “Skills on How to Show different Adsense Ads at WordPress”

How to using PHP to delete wordpress coments?

Sometimes there are thousands wordpresss comments there, it is too difficult to delete them. Any method to delete them one time without login phpmyadmin?

The answer is yes, the follow code can help you.

include(‘wp-config.php’);
mysql_query(“truncate table wp_comments;”);

Copy the code to file delete_wp_comment.php, and put the file under your blog. Run it, all comments will be deleted!

If you only want to delete spam or trash comments, please visit http://kingphp.com/160.html , and just change some code. Very simple!

Using PHP to Export Mysql Data to Excel

 

<?php 
$DB_Server = “localhost”;   
$DB_Username = “put your user name here”;   
$DB_Password = “put your password here”;   
$DB_DBName = “put your database name here”;   
$DB_TBLName = “put your table name here”;   
  
$savename = date(“YmjHis”);  // excel file name
$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password) or die(“Couldn’t connect.”);   
mysql_query(“Set Names ‘utf-8′”); Continue reading “Using PHP to Export Mysql Data to Excel”

Mass Delete Comments from WordPress

Pending links, Spam links, or Trash links with a WordPress powered blog can grow really quickly and most is spam. Word Press allows you to remove such comments but only 20 at a time. What if you have thousands pending links, spam links or trash links need to be deleted? You will wast a lot time if you delete them via WordPress Blog own functions. Here we will teach you how to delete them via phpmyadmin! Continue reading “Mass Delete Comments from WordPress”

Some tips on adding ads code to wordpress

If we do not want ads code shows at wordpress homepage, but at the other pages, we can use the following code:
<?php if (($wp_query->current_post == 0)and (!is_home())) : ?>
<div style=”float:right;margin-left:20px”><br>
Buy sunglasses online.
</div>
<?php endif; $postcnt++; ?>

If we want the ads codes show at all pages, we can use the following codes: Continue reading “Some tips on adding ads code to wordpress”

Use WordPress to Setup Multi Blogs Under One Mysql Database

We can use Mu to setup multi wordpress blogs. If you do not want to do so, you can use wordpress to setup multiy blogs also.

 For example, we want to set up two blogs: www.glassespeople.com ,and http://blog.glassespeople.com, we only add the following code at wp-config.php: Continue reading “Use WordPress to Setup Multi Blogs Under One Mysql Database”

2 Methods to show wordpress lastest posts at other site

Method one, we can show other wordpress posts at our site by using  simplepie.inc, download a wordpress plugin, named “simplepie-core”, and upload simplepie.inc to your site root, you can rename simplepie.inc to other name also, ie, eyeglassframes.inc.

Then add the following code at your own site .php file. Continue reading “2 Methods to show wordpress lastest posts at other site”

Display Domain Name

How would I display the domain name of the page I am at. Lets say it it http://www.eyeglasseshut.com/comfortable-prescription-eyeglasses.htm and I want to display desilva.biz. Exactly like that. No www, or http:// included.

In fact, it is very use to let PHP do such thing:

$hostname = $_SERVER['SERVER_NAME'];
$hostname = str_replace(‘www.’, , $hostname);

echo $hostname;

How to add 10 hot wordpress posts

If you want to add 10 host post at your right bar, just copy and past the following code:

<h2>Hot PHP Posts</h2>
<ul>
<?php $result = $wpdb->get_results(“SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 10″);
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href=”<?php echo get_permalink($postid); ?>” title=”<?php echo $title ?>”>
<?php echo $title ?></a> (<?php echo $commentcount ?>)</li>
<?php } } ?>
</ul>

Using PHP to Generate Strong Password

If you want to have very strong password to protect your account, here is the code for :

<code>
<?php
 
function generatePassword($length=9, $strength=0) {
    $vowels = ‘aeuy’;
    $consonants = ‘bdghjmnpqrstvz’;
    if ($strength & 1) {
        $consonants .= ‘BDGHJLMNPQRSTVWXZ’;
    }
    if ($strength & 2) {
        $vowels .= “AEUY”;
    }
    if ($strength & 4) {
        $consonants .= ’23456789′;
    }
    if ($strength & 8) {
        $consonants .= ‘@#$%’;
    }
 
    $password = ”;
    $alt = time() % 2;
    for ($i = 0; $i < $length; $i++) {
        if ($alt == 1) {
            $password .= $consonants[(rand() % strlen($consonants))];
            $alt = 0;
        } else {
            $password .= $vowels[(rand() % strlen($vowels))];
            $alt = 1;
        }
    }
    return $password;
}
 
?>
</code>