To add class to wordpress wysiwyg editor copy this php code to your theme function.php file

if ( ! function_exists('tdav_css') ) {
	function tdav_css($wp) {
		$wp .= ',' .get_bloginfo('stylesheet_directory') . '/style_css.css';
	return $wp;
	}
}
add_filter( 'mce_css', 'tdav_css' );

Here you add new style file. In this file create your new css classes. Now go to wysiwyg editor and there you will see your created classes. Use them for table or links. 🙂

Sometimes we need to get depth of posts or pages in wordpress. Now you can do it easy with function


function getDepth($id = '', $depth = '', $i = 0)
{
 global $wpdb;
 global $post;
 if($depth == '')
 {
 if(is_page())
 {
 if($id == '')
 {
 $id = $post->ID;
 }
 $depth = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE ID = '".$id."'");
 return getDepth($id, $depth, $i);
 }
 }
 elseif($depth == "0")
 {
 return $i;
 }
 else
 {
 $depth = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE ID = '".$depth."'");
 $i++;
 return getDepth($id, $depth, $i);
 }
}

Copy function getDepth() in your function.php file. Call it from your template, for example <?php echo getDepth($post_ID);?>

and it will return your post depth in your site.

Try, I hope it will help you.

Sometimes it happens that working with WordPress, we need to get children off current page. There is a fairly simple decision to do this. We can use the WordPress function get_pages (). Here is the code example of how this can be done.

<? $pages = get_pages('child_of='.$post->ID.'&sort_column=post_title');
		?>
		<ul><?
		foreach($pages as $page)
		{ ?>
			<li class="page_item"><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></li>
		<?php
		}
?></ul>

In this example we get page title and page link.

Sometimes it is necessary to have page content in WordPress. This can be done quite easily. Use this code

 
 $pageId = 68;

			global $wpdb;
			$sql_query = 'SELECT DISTINCT * FROM ' . $wpdb->posts .
			' WHERE ' . $wpdb->posts . '.ID=' . $pageId;
			$posts = $wpdb->get_results($sql_query);
			if(!empty($posts))
			{
				foreach($posts as $post)
				{
					print_r(nl2br($post->post_content)); 
				}
			}

There $pageId, use your page ID, which content you want to see.

Creating, editing and deleting the user account is an important thing in any CMS. We can easily manage user in wordpress sites too. There are a lot of plugins which helps us create User profile and manage there profile.

But in wordpress deleting User from wordpress is not easy. Here in this article we will show how can we easily delete the user account without administrator permission.

Using following wordpress plugin we can achieve this functionality.

User Self Delete

This plugin will allow your users to delete their own account without any need for interaction on the administrator’s behalf.

When user want to delete their account, they are taken to page where they must enter the word “yes” . Once they type “yes” and press the delete account button, they are redirected to the login page and they no longer exist as a user in site.

If you are making the wordpress plugin, many times we need to create new tables. You will see how easily we can create the wordpress plugin with new table in database.
Using following code:

global $my_db_version;
$my_db_version = "1.0";
function my_install () {
global $wpdb;
global $my_db_version;
$table_name = $wpdb->prefix . "liveshoutbox";
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
$sql = "CREATE TABLE " . $table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
name tinytext NOT NULL,
UNIQUE KEY id (id)
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
$rows_affected = $wpdb->insert( $table_name, array('name' => $welcome_name) );
add_option("my_db_version", $my_db_version);
}
}

Now that we have the initialization function defined, we want to make sure that WordPress calls this function when the plugin is activated by a WordPress administrator. To do that, we will use the activate_ action hook. If your plugin file is wp-content/plugins/plugindir/pluginfile.php, you’ll add the following line to the main body of your plugin:


register_activation_hook(__FILE__,'my_install');

Seo WordPress Plugins

1. All in One SEO Pack – By far the gold standard of SEO plugins, “All in One” provides a multitude of easy to understand options to get your blog up to par SEO wise. 99% of WordPress users will agree when I say this is an absolute must have when it comes to plugins. With over 2 million downloads and growing, you can’t go wrong.

2. SEO Title Tag – Although the plugin above can control title tags on your WordPress blog, this plugin is an outstanding solution to optimize and customize every title tag on your blog.

3. HeadSpace2 SEO – This handy dandy SEO plugin will allow you to customize meta-data for nearly every aspect of your blog including posts, pages, categories, home page, search pages, author pages, and even 404 pages. This is a super alternative to All in One SEO Pack, just not quite as popular.

Continue reading

I’ve moved my site in the last few days to a new dedicated server. I’ve decided to switch to Lighttpd. Now I can say that I’m fairly satisfied with the move.

But after I transfered the domain to the new server I’ve found out that none of my inner pages are accessible. The reason, as it turned up pretty quickly, is that the WordPress depends on Apache’s mod_rewrite to create the clean URLs (the so called permalinks).

Continue reading

1. Introduction

WordPress is gaining more and more popularity each day, not just as a blogging platform but also as a basic CMS, thus improving and extending its basic functionality becoming a day-to-day necessity for a lot of developers. Fortunately, the WordPress developers have foreseen these needs and added the possibility of customizing the basic functionality by adding plugins. Basicaly, a WordPress plugin is a (more or less) stand-alone piece of code that can be executed in different sections and stages within a page or site.

Let’s get started!

Continue reading