Comment notification plugin in wordpress

May be it was end of the last year, I was assigned to finish a wordpress project which was taking way too long time to deliver. I was away from wordpress development for more than two years. So after jumping into the project I found most of the user requirements are  bit different than the general.wordpress-logo

One of the requirements was to wordpress admin should be able to use “admin comment” section to reply the comments as email whether the user is subscribed to the post/comment or not. If some one comment into the content and if admin approved it with reply, the user will have to receive an email with the reply.

Worpdress provide a nice action call “comment_post“, I wrote a simple method which will be executed after every comment and check is it approved or not and will send an email. Check the full plugin from github

By the way, without subscriptions into the post and comment, sending email is not “ethical” so if you want to use it use in your own risk.

Also feel free to fork it if you want to add/customize 🙂


WordPress Loop for customizing Theme,plugins .

As we all know wordpress is the light weight web CMS.It is easy to customize to meet your customers need.
The wordpress loop(wp loop) play the role to fetch the required posts from db and show it.If you previously worked with the may be familiar with it.If not,you can figure it out just going to wordpress themes folder(wp-content/themes) and open the index.php file.The codes are :

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

Here have_posts(),the_posts() are both the functions that access the property method of Wp_query() class.Wp_query() locates at “wp-incldes/query.php”

In some of the themes “query_posts()” is used but for customization tasks,its better to create an instantiate the own “Wp_Query()” for custom loop.
Lets start to customize a loop.Just remove the previous loop, and create a new instantiate of “Wp_Query()”.And declare the category of the posts you want to display through the loop.

$my_query = new WP_Query('p=85,111');  //retrieving only post no 85 and 111 
have_posts()) :
	while ($my_query->have_posts()) :

You can customize the loop using different kinds of parameters in based of posts,category etc.
For having more query specific result you can pass specific arugements as form of array.Code example will be like below:

$args = array('post_type'=>'post','post__in'=>array('1','4','6'));	
$my_query = new WP_Query($args); 		
if ($my_query->have_posts()) : 		
while ($my_query->have_posts()) :		
$my_query->the_post(); 	?>

You can use these kinds of customized loop for having different posts and pages.
For details about Wp_Query,Click Here

For customizing any plugin related to post display(Ex. gallery plugins)you can use custom loop.Also in differenet conditional posts can be displayed using custom loop.

For having further details about loop,Click Here