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;

How to Remove P and Br tags in WordPress posts?

Open functions.php in your current active theme.
Add following lines


remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

How to get last inserted row id from wordpress database?

global $wpdb;
/** insert query here with $wpdb**/
/** insert query here with $wpdb**/
 $lastId = $wpdb->insert_id; //This is last insert id

How to get wordpress post featured image URL?

if (has_post_thumbnail( $post->ID ) ){ 
  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
  echo $image[0];//image url 
}

What is use of __() and _e() functions in wordpress?

These are function used when you website multilingual.
each of this function have two parameter.
1st parameter: String which you want to convert from one language to another.
2nd parameter: domain name.

 $translatedText = __( 'TEXT_FOR_TRANSLATION', 'textdomain' ); //This will return the translated text
 _e( 'TEXT_FOR_TRANSLATION', 'textdomain' ); //This will print the translated text

How to turn off the Notice/Warning from my wordpress website?

Open the wp-config.php file and WP_DEBUG set the false.

define('WP_DEBUG', false );

How do I ge the version of wordpress?

echo bloginfo('version');
Above is get from below file.

You can check in wp-includes/version.php

$wp_version = '4.1.2';

How to get the current page name in WordPress?

You can get the page name from below of two

$slug = basename(get_permalink());
OR
$pagename = get_query_var('pagename');  

Template Files List for development WordPress Theme?

Here is the list of the Theme files recognized by WordPress. Of course, your Theme can contain any other stylesheets, images, or files.
style.css: The main stylesheet. This must be included with your Theme, and it must contain the information header for your Theme.
rtl.css: The rtl stylesheet. This will be included automatically if the website’s text direction is right-to-left. This can be generated using the RTLer plugin.
index.php: The main template. If your Theme provides its own templates, index.php must be present.
comments.php: The comments template.
front-page.php: The front page template.
home.php: The home page template, which is the front page by default. If you use a static front page this is the template for the page with the latest posts.
single.php: The single post template. Used when a single post is queried. For this and all other query templates, index.php is used if the query template is not present.
single-{post-type}.php
The single post template used when a single post from a custom post type is queried. For example, single-book.php would be used for displaying single posts from the custom post type named “book”. index.php is used if the query template for the custom post type is not present.
page.php: The page template. Used when an individual Page is queried.
category.php: The category template. Used when a category is queried.
tag.php: The tag template. Used when a tag is queried.
taxonomy.php: The term template. Used when a term in a custom taxonomy is queried.
author.php: The author template. Used when an author is queried.
date.php: The date/time template. Used when a date or time is queried. Year, month, day, hour, minute, second.
archive.php: The archive template. Used when a category, author, or date is queried. Note that this template will be overridden by category.php, author.php, and date.php for their respective query types.
search.php: The search results template. Used when a search is performed.
attachment.php: Attachment template. Used when viewing a single attachment.
image.php: Image attachment template. Used when viewing a single image attachment. If not present, attachment.php will be used.
404.php: The 404 Not Found template. Used when WordPress cannot find a post or page that matches the query.

Essential plugins for WordPress?

https://wordpress.org/plugins/wordpress-seo/ (Best SEO Plugin)
https://wordpress.org/plugins/google-sitemap-generator/ (sitemap)
https://wordpress.org/plugins/w3-total-cache/ (caching)
https://wordpress.org/plugins/wp-smushit/ (optimizing image files)
https://wordpress.org/plugins/wp-optimize/ (Simple but effective plugin allows you to extensively clean up your WordPress database and optimize it without doing manual queries: )

Security:
https://wordpress.org/plugins/wordfence/
https://wordpress.org/plugins/login-lockdown/

What is plugin in WordPress?

Plugins are ways to extend and add to the functionality that already exists in WordPress. The core of WordPress is designed to be lean and lightweight, to maximize flexibility and minimize code bloat. Plugins then offer custom functions and features so that each user can tailor their site to their specific needs.

Developer Features in a WordPress?

For developers, WordPress Have lots of goodies packed under the hood that you can use to extend WordPress in whatever direction takes your fancy.
  • Plugin System
  • Theme System
  • Application Framework
  • Custom Content Types
  • The Latest Libraries

Different between WordPress.com vs WordPress.org?

WordPress.com (fully hosted)
Focus on your beautiful content, and let us handle the rest.
WordPress.org (self-hosted)
Get your hands dirty, and host your website yourself.

Which is the best multi-lingual plugin for wordpress?

Keeping all the limitations in mind, WPML would be the best multi-lingual plugin for wordpress .

What are the plugins you can use to create contact form in WordPress?

To create a contact form in WordPress you can use plugin like Gravity forms or also you can use a free plugin contact form 7

Is it possible to rename the WordPress folder?

Yes, it is possible to rename the WordPress folder.  If WordPress is already installed you have to login to the weblog as the administrator and then change the settings
WordPress address (URI)  :
Blog address( URI) :
After making the changes, you can rename the folder or directory with the WordPress file in it.

What is the prefix of wordpress tables by default?

By default, wp_ is the prefix for wordpress.

What are the rules that you have to follow for wordpress plugin development?

  • Create a unique name
  • Create the plugin’s folder
  • Create a sub-folder for PHP files,  translations and assets
  • Create the main plug-in file and fill in header information
  • Create activation and de-activation functions
  • Create an uninstall script
  • Create a readme.txt file
  • To detect paths to plugin file use proper constants and functions

What are the positive aspects of wordpress?

Few positive aspects of wordpress are
  • Easy installation and upgrade
  • In-built SEO engine
  • Easy theme system
  • Flexibility
  • Multilingual- available in more than 70 languages
  • Own data- no unwanted advert on your website
  • Flexibility and Easy publishing option