WordPress is commonly used CMS technology to develop websites. here we have mentioned most frequently asked WordPress Interview Questions and Answers specially for freshers and experienced.
1. What is WordPress?
Ans:
Word press is a best Open Source CMS which allows it to be used free of cost. You can use it on any personal or commercial website without having to pay a single penny for it. It is built on PHP/MySQL (which is again Open Source) and licensed under GPL.
2. How safe is a website on WordPress?
Ans:
The word press is safe to operate, but still, it is suggested to keep updating with the latest version of WordPress to avoid hacking.
3. Are there any limitations to a WordPress website?
Ans:
You can use WordPress for e-commerce sites, membership sites, photo galleries and any other type of site you can think of. The website is created using the same HTML code as any other site, so there are no limitations there either.
4. Do you need to have a blog in order to use WordPress for a site?
Ans:
WordPress was originally used as blogging software though it has since become popular for the website also. It is not necessary to have a blog to use WordPress. Still having a blog is commendable as it will help in search engine optimization.
5. From SEO point of view is WordPress helpful? Will it show the website on Google?
Ans:
It is one of the benefits of using WordPress; it has inbuilt SEO search engine. Also, you can have an additional plug-in in WordPress to help with SEO and rank on a popular search engine like Google.
6. What is the current version of WordPress?
Ans:
You need to quote the current version of WordPress available in the market along with the release date.
7. What are the types of hooks in WordPress and mention their functions?
Ans:
There are two types of hooks 1) Action hooks 2) Filter hooks
Hooks allow a user to create WordPress theme or plugin with shortcode without changing the original files. Action hooks allow you to insert an additional code from an outside resource, whereas, Filter hooks will only allow you to add content or text at the end of the post.
8. What do you mean by a custom field in WordPress?
Ans:
The custom field is a meta-data that allows you to store arbitrary information in the WordPress post. Through custom field, extra information can be added to the post.
9. What are the positive aspects of WordPress?
Ans:
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
10. What are the rules that you have to follow for WordPress plugin development?
Ans:
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 the 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
11. What is the prefix of WordPress tables by default?
Ans:
By default, wp_ is the prefix for WordPress.
12. Why does WordPress use MySQL?
Ans:
MySQL is widely available database server and is extremely fast. It is an open source, and it is available at no cost also it is supported by many low-cost Linux hosts so its easy for anyone to host their website.
13. Is it possible to rename the WordPress folder?
Ans:
Yes, it is possible to rename the WordPress folder. If WordPress is already installed, you have to log in 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.
14. How many tables are there in WordPress by default?
Ans:
There are about 11 tables in WordPress by default. Note: With succeeding releases of WordPress this number will change. You need to check phpMyAdmin to determine the number of tables in a vanilla version of latest WordPress installation.
15. What is WordPress loop?
Ans:
To display post WordPress use PHP code, this code is known as a loop.
16. How can you disable the WordPress comment?
Ans:
If you go to the dashboard under options “discussion, there is a comment “ Allow people to post comment” try unchecking the comment.
17. What are the steps you can take if your WordPress file is hacked?
Ans:
- Install security plugins like WP security
- Re-install the latest version of WordPress
- Change password and user-ids for all your users
- Check your themes and plug-ins are up to date
18. What are the template tags in WordPress?
Ans:
In WordPress template tags is a code that instructs WordPress to “do” or “get” something.
19. Does WordPress have cookies?
Ans:
Yes, WordPress has cookies, and WordPress uses cookies for verification of users while logged in.
20. In which cases you don’t see plugin menu?
Ans:
You can’t see your plugin menu when the blog is hosted on free wordpress.com as you cannot add plugin there. Also, if you do not have an account of an administrator level on your WordPress is not possible to see the plugin.
21. At what instance you get locked out of your WordPress admin and look at your website as a blank screen?
Ans:
This would likely happen when you have pasted the code from a website with wrong formats, also when you have pasted the code in an incorrect location. It may also happen when your IP is banned
22. Why you use a static front page in WordPress?
Ans:
Some WordPress users want their WordPress installation to be more than a blog site. To give their page a look more like a real website page some users use static front page.
23. What are the plugins you can use to create a contact form in WordPress?
Ans:
To create a contact form in WordPress, you can use a plugin like Gravity forms or also you can use a free plugin contact form 7.
24. Why does widget not show up in the sidebar?
Ans:
While using a widget, you have to ensure whether your theme supports the widget and if it does then, it must show the sidebar. If in any case if it happens that you don’t see the sidebar, then it might be missing the “function.php” file or file similar to that. This can also happen if you have forgotten to save the changes in the widget or to refresh the older display of the page.
25. Is there any limitation for using WordPress?
Ans:
No, there is no limitation for using WordPress. WordPress can be used for innumerable purpose membership site, e-commerce site, photo-gallery and many more.
26. How is creating a site on wordpress.org different from wordpress.com?
Ans:
Most of the things are similar in both except the choices of themes and the use of plugins.
27. Why is wordpress.com considered more secure than wordpress.org?
Ans:
WordPress.com is considered more secure than wordpress.org because they limit the themes and also does not allow installing plugins. However, the security is more dependable on how the hosting company is hosting your website(wordpress.org) & also what are the steps they are taking to prevent the security problems.
28. Do de-activated plugins slow down a WordPress site?
Ans:
No, de-activated plugins cannot slow down the WordPress site. WordPress only loads the active plugins and ignores everything else.
29. In what case we cannot recommend WordPress to our client?
Ans:
We cannot recommend WordPress in the following situation:
- If the client is working on a non-CMS base project
- If a site wants complex or innovative e-commerce
- In case of enterprise intranet solution
- Sites are requiring custom scripting solutions.
30. What are the essential features you look for a theme?
Ans:
Theme selection differs according to the requirement, but an ideal theme would be something that would not restrict to use the number of pages, plugins or static homepage.
31. What is a Child Theme?
Ans:
The child theme is an extension of the parent theme. If you make changes to the main/parent theme, any update will undo the changes. With a child theme, the customizations are preserved on an update.
32. How can you create a static page with WordPress?
Ans:
To create a static page in WordPress, in the page section you have to upload a PHP file to the server in the theme folder, and then select that as your template. It allows you to add any page and look that you wanted for your blog and it will remain static.
33. Is there any other CMS better WordPress?
Ans:
WordPress is no doubt a good CMS, but Drupal and Joomla are among the best CMS you can work with.
34. Which is the best multilingual plugin for WordPress?
Ans:
Keeping all the limitations in mind, WPML would be the best multilingual plugin for WordPress.
35. Can you update your own content on the site?
Ans:
It depends on the type of the site or project, but yes one can update their own content on the site.
36. What are meta-tags?
Ans:
Meta-tags are keywords and description used to display website or page information.
37. What should one use for plugin development — custom post types or custom database tables?
Ans:
There is no specific preference for plugin development; it depends on what type of plugin’s one has to develop. Though few recommend custom post type, as it has few benefits compared to a custom database table.
38. Can you host WordPress using Amazon web services such as EC2, RDS, EBS, etc.?
Ans:
Yes, you can host using Amazon web services.
39. Is there any way to write series in WordPress?
Ans:
You can use organize series plugin to write series in WordPress.
40. What are the reasons why one should not hack WordPress core file?
Ans:
The best reason not to hack the core files is that whatever you might be doing has to be reworked as a patch.
41. What are hooks and define types of hooks in WordPress?
Ans:
Hooks are provided by WordPress to allow your plugin to ‘hook into’ the rest of WordPress; that is, to call functions in your plugin at specific times, and thereby set your plugin in motion. There are two kinds of hooks:
Actions Hooks: Actions hooks are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Your plugin can specify that one or more of its PHP functions which are executed at these points, using the Action API.
Filters Hooks: Filters hooks are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Your plugin can specify that one or more of its PHP functions which are executed to modify specific types of text at these times, using the Filter API.
- Actions Functions:
- has_action()
- add_action()
- do_action()
- do_action_ref_array()
- did_action()
- remove_action()
- remove_all_actions()
- Filter Functions:
- has_filter()
- add_filter()
- apply_filters()
- apply_filters_ref_array()
- current_filter()
- merge_filters()
- remove_filter()
- remove_all_filters()
42. What are the template tags in WordPress?
Ans:
A template tag is code that instructs WordPress to “do” or “get” something. Like in header.php we will use the tag bloginfo(‘name’) to get “Site Title” from wp-options table which is set in Setting > General at WordPress dashboard.
The the_title() template tag is used to display the post title.
wp_list_cats() is for display categories.
get_header() for getting header.
get_sidebar() for display the sidebar on page.
get_footer() for get the footer content on page.
43. How to write the short code in WordPress php file?
Ans:
Using do_shortcode() function inside of php echo tag. A very simple solution is to use the do_shortcode() function inside a PHP echo tag. Short code is used in WordPress post or page and text box widget and php file.
44. What are rules to follow in WordPress plugin development?
Ans:
- Find a unique name
- Setup a prefix (related to your brand)
- Create the plugin’s folder
- Create sub-folders for PHP files, assets, and translations
- Create the main plugin file and fill in obligatory header information
- Create a readme.txt file
- Use proper constants and functions to detect paths to plugin files
- Create additional PHP files and include them inside the main one
- Create activation and deactivation functions
- Create an uninstall script
45. What are the steps you can take if your WordPress file is hacked?
Ans:
- Install security plugin like WP security
- Re-install the latest version of WordPress
- Change password and user-ids for all your users
- Check your themes and plugins are up to date
46. In which cases you don’t see plugin menu?
Ans:
You can’t see your plugin menu when the blog is hosted on free wordpress.com as you cannot add plugin there. Also, if you do not have an account of an administrator level on your WordPress dashboard, it is not possible to see plugin.
47. What is the difference between the wp_title and the_title tags?
Ans:
wp_title() function is for use outside “The Loop” to display the title of a Page. the_title()on the other hand is used within “The Loop“.
48. How to modify the parent theme behavior within the child theme?
Ans:
The child theme could optionally override other template files like author.php, category.php, functions.php, style.css etc. The WordPress framework first looks for a template file in the child theme directory and then will pick it up from the parent directory if not found.
49. How to Create Custom Post Type?
Ans:
Custom post types are new post types you can create. A custom post type can be added to WordPress via the register_post_type() function. This function allows you to define a new post type by its labels, supported features, availability and other specifics.
50. How to check if a page exists by url?
Ans:
You can use get_page_by_path() function. Refer check page existance by url detailed article.
51. What do next_posts_link() and previous_posts_link() do?
Ans:
Because post queries are usually sorted in reverse chronological order, next_posts_link()usually points to older entries (toward the end of the set) and previous_posts_link() usually points to newer entries (toward the beginning of the set).
52. How to create mailchimp or vertical response campaign for newsletter subscribers & link with WordPress ?
Ans:
First Create List & Campaign on mailchimp/ WordPress account . Then subscribe users from WordPress in mailchimp list by plugin or manual hard code webform.
53. What options are there to implement a multi language site ?
Ans:
WordPress has no bi/multi-language feature built in by default. The other road would be to extend the site with Add-ons like plugins and themes that have multi-language features built-in.
54. How will you retrieve adjacent posts (next/previous) within the same category?
Ans:
We can retrieve previous post using get_adjacent_post() function and providing it ‘true‘ and taxonomy name in first and last parameters respectively. Setting third parameter to false will bring next adjacent post in front of you.
55. How to create Custom Taxonomy specific to a Custom Post type?
Ans:
First of all if you want to show taxonomy metabox only to custom post type then register the taxonomy to only that custom post type by passing the custom post type name as argument in register_taxonomy(). By doing this the taxonomy metabox appears only to custom post type.
56. How can I stop WordPress from prompting me to enter FTP information when doing updates?
Ans:
If you edit your wp-config.php file you can preload these FTP settings as constants read by WordPress. Keep in mind, on a shared host, you should be mindful of possible security implications.
57. How To Activate Plugins via Code?
Ans:
Plugins are stored in an array in the ‘active_plugins‘ option. The array contains the file path to each plugin that is active. To activate a plugin you need to determine what it’s path will be, then pass that path to activate_plugin($plugin_path).
Before you can call activate_plugin() you need to include the plugin.php file from wp-admin/includes/. You should also check to make sure your plugin isn’t already active. The result looks something like this.
58. What’s the difference between site_url() and home_url()?
Ans:
The site_url() will always be the location where you can reach the site by tacking on /wp-admin on the end, while home_url() would not reliably be this location. The home_url() would be where you have set your homepage by setting General > Settings “Site Address (URL)” field.
59. How to Link External jQuery/Javascript files with WordPress
Ans:
Add your own scripts via wp_enqueue_script() in your template’s functions.php, appropriately setting dependences on jQuery, and wp_head() will add the scripts for you.
60. How to set global variable in functions.php
Ans:
Pure PHP question, really.
global $urlSmall;
$urlSmall = $thumbSmall['0'];
If you declare the variable with the ‘global‘ keyword when you initialize it, it will be available thereafter.
61. How to retrieve an image attachment’s alt text?
Ans:
The wp_get_attachment_image() function which will return an HTML string containing these attributes:
- ‘src‘
- ‘class‘
- ‘alt‘
- ‘title‘.
62. Consider the following code snippet. Briefly explain what changes it will achieve, who can and cannot view its effects, and at what URL WordPress will make it available.
add_action('admin_menu', 'custom_menu');
function custom_menu(){
add_menu_page('Custom Menu', 'Custom Menu', 'manage_options', 'custom-menu-slug', 'custom_menu_page_display');
}
function custom_menu_page_display(){
echo '
Hello World
‘;
echo '
This is a custom page
‘;
}
Ans:
This will add a new menu item labelled “Custom Menu” to the side menu of the WordPress dashboard. When you click on this menu item, WordPress will call the function ‘custom_menu_page_display’ and show a page titled “Custom Menu”, with the heading “Hello World” and a paragraph that reads “This is a custom page”.
With default settings and roles, admins can view it and all lower roles can’t. In fact this menu item will only be visible to users who have the privilege to “manage options” or change settings from WordPress admin dashboard.
The admin custom page will be made available at this (relative) URL: “?page=custom-menu-slug”.
63. How would you change all the occurrences of “Hello” into “Good Morning” in post/page contents, when viewed before 11AM?
Ans:
In a plugin or in theme functions file, we must create a function that takes text as input, changes it as needed, and returns it. This function must be added as a filter for “the_content”.
It’s important that we put a little effort to address some details:
Only change when we have the full isolate substring “hello”. This will prevent words like “Schellong” from becoming “sgood morningng”. To do that we must use “word boundary” anchors in regular expression, putting the word between a pair of “\b”.
Keep consistency with the letter case. An easy way to do that is to make the replace case sensitive.
function replace_hello($the_content){
if(current_time('G')<=10){
$the_content=preg_replace('/\bhello\b/','good morning',$the_content);
$the_content=preg_replace('/\bHello\b/','Good Morning',$the_content);
}
return $the_content;
}
add_filter('the_content', 'replace_hello');
64. What is the $wpdb variable in WordPress, and how can you use it to improve the following code?
function perform_database_action(){
mysql_query(“INSERT into table_name (col1, col2, col3) VALUES ('$value1','$value2', '$value3');
}
Ans:
$wpdb is a global variable that contains the WordPress database object. It can be used to perform custom database actions on the WordPress database. It provides the safest means for interacting with the WordPress database.
The code above doesn’t follow WordPress best practices which strongly discourages the use of any mysql_query call. WordPress provides easier and safer solutions through $wpdb.
The above code can be modified to be as follows:
function perform_database_action(){
global $wpdb;
$data= array('col1'=>$value1,'col2'=>$value2,'col3'=>$value3);
$format = array('%s','%s','%s');
$wpdb->insert('table_name', $data, $format);
}
65. Consider the following code snippet and explain the purpose of wp_enqueue_script. Can you figure out if something is wrong in the snippet?
add_custom_script();
function add_custom_script(){
wp_enqueue_script(
'jquery-custom-script',
plugin_dir_url( __FILE__ ).'js/jquery-custom-script.js'
);
}
Ans:
wp_enqueue_script is usually used to inject javascript files in HTML.
The script we are trying to queue will not be added, because “add_custom_script()” is called with no hooks. To make this work properly we must use the wp_enqueue_scripts hook. Some other hooks will also work such as init, wp_print_scripts, and wp_head.
Furthermore, since the script seems to be dependent on jQuery, it’s recommended to declare it as such by adding array(‘jquery’) as the 3rd parameter.
Proper use:
add_action(‘wp_enqueue_scripts’, ‘add_custom_script’);
function add_custom_script(){
wp_enqueue_script(
'jquery-custom-script',
plugin_dir_url( __FILE__ ).'js/jquery-custom-script.js',
array( 'jquery')
);
}
66. Is WordPress safe from brute force login attempts? If not, how can you prevent such an attack vector?
Ans:
No, WordPress on its own is vulnerable to brute force login attempts.
Some good examples of actions performed to protect a WordPress installation against brute force are:
- Do not use the “admin” username, and use strong passwords.
- Password protect “wp-login.php”.
- Set up some server-side protections (IP-based restrictions, firewall, Apache/Nginx modules, etc.)
- Install a plugin to add a captcha, or limit login attempts.
67. The following line is in a function inside a theme’s “function.php” file. What is wrong with this line of code?
wp_enqueue_script('custom-script', '/js/functions.js');
Ans:
Assuming that “functions.js” file is in the theme’s “js/” folder, we should use ‘get_template_directory_uri()’. ‘/js/functions.js’ or the visitors’ browser will look for the file in the root directory of the website.
About the author
One comment
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
With thanks! Valuable information!