Saturday, 5 December 2015

How can delete a user without deleting the post and comments in wordpress?

1. Login as Administrator (must be not login to whom you are going to delete).
2. Go to User Listing.
3. Click on check box in front of user to whom you want to delete. See below screenshot.

wordpress admin user listing



4. Click on delete icon. It will bring to you new page.
5. Now assign all post to another user/administrator. See below Screenshot.
wordpress admin user delete page

6. Click on "Confirm Deletion". User deleted successfully.

How to change the author of a post in Wordpress

Change Author by manually edit the POST, Follow the simple steps. 

  • Login as Administrator.
  • Go to Posts.
  • Edit the post which's author you want to change.
  • Now you are on edit post.
  • Scroll down till you get "Author List" under "Author".
  • Now select the Author from dropdown/selectbox to whom you want to assign. 
  • See screenshot below

How to send Email in wordpress

you can set the receipt, subject, description, reply-to and header  in email.


$receipt = "user@no-spam.ws"; 
$subject = "This is subject";
$content = 'This is conent of the email.


http://www.web-technology-experts-notes.in';
/** Set the Reply -optional field **/
$headers = array(
 'Reply-To' => "replyto@no-spam.ws"
);
/** Set the Reply -optional field **/


/** Send the Html email - optional field **/
add_filter( 'wp_mail_content_type', 'set_html_content_type' );
/** Send the Html email - optional field **/

$status = wp_mail($receipt, $subject, $content, $headers);
if($status){
echo 'Sent Successfully';
}else{
echo 'Not send';
}
  

How do I get wordpress global variable and functions in custom file

if your custom file is at WP blog root folder.
Just add the following line in top. This will load wordpress blog and you can access global variables.

require( 'wp-load.php' );
global $wp_query;

How to check admin login or Not?

if(is_admin()) { 
/** Write your code here */

/** Write your code here */
}

How do I add Syntax Highlighting on wordpress.com?

As you can't install plugin for syntax high lighting in wordpress.com, you can use existing syntax highligher.

[sourcecode language='python']

[/sourcecode]

How do I get current taxonomy "term id" on wordpress?

$obj = get_queried_object();
echo $obj->term_id;