Friday, 12 December 2014

Wordpress Interview Questions and Answers

Wordpress Interview Questions and Answers

Wordpress is opensource content management system where you can add/update/delete contents from admin section. Content may be text, images or videos etc. 

Because it is opensource, so you can update the code at free of cost. Wordpress built on PHP/MySQL/javascript (which is also an Open Source) and licensed under GPL. You can create different types of websites whether it is personal / commercial website. Today most of developer prefer wordpress as its easy to install and millions of plugins, themes are available over internet at free of cost & you can do customization.  




Question: What is Wordpress?
Wordpress is Content Management System which have robust admin section. From Admin section you can manage the website text/html, image & videos etc. You can easily manage pages & posts. You can set meta title, meta description & meta keywords for each post. It gives you full control over post & pages .



Question: Is Wordpress opensource?
Yes, Wordpress is opensource and you can do customization as per your requirement. Wordpress is built in PHP/MySql/javascript/jQuery which is also an opensource.



Question: What is current stable version of wordpress?
4.1 released in November 20, 2014



Question: What kind of website can I build with WordPress?
WordPress was originally developed as a blogging in 2003 but now it has been changed a lot. you can create personal website as well as commercial website.
Following types of websites can be built in wordpress:
  • Informative Website
  • Personal Website
  • Photo Gallery
  • Business Website
  • E-Commerce website
  • Blogging
Today, million of free/paid wordpress themes, wordpress plugin are available which help you to create as per your requirement.



Question: From where you can download plugins?
https://wordpress.org/plugins/



Question: From where you can download themes?
https://wordpress.org/themes/



Question: What is Hooks in wordpress?
Hooks allow user to create WordPress theme or plugin with shortcode without changing the original files.



Question: What are the types of hooks in WordPress?
Following are two types of hooks
A) Action hooks: This hooks allow you to insert an additional code.
B) Filter hooks: Filter hooks will only allow you to add a content or text at the end of the post.



Question: What are positive aspects of wordpress?
  • Easy to install and upgrade the wordpress
  • In-built SEO engine and you can manage the URL and meta data as per your requirement.
  • Easy to themes and plugins
  • Multilingual available in more than 70 languages
  • Can be do customization as per requirement
  • Lots of free/paid themes/plugin available




Question: What is the default prefix of wordpress tables?
wp_ is the prefix for wordpress but you can change at the time of installation.



Question: What is WordPress loop?
The Loop is PHP code used by WordPress to display posts.



Question: What are the template tags in WordPress?
Template tags is a code that instructs WordPress to "do" or "get" something



Question: What are meta tags in wordpress?
Meta-tags are keywords and description used to display website.



Question: How to secure your wordpress website?
  • Install security plug-ins like WP security
  • Change password of super admin OR other admin
  • Add security level checks at server level like folder/file permission.



Question: How many tables a default WordPress will have?
Following are main table in wordpress:
  • wp_commentmeta
  • wp_comments
  • wp_links
  • wp_options
  • wp_postmeta
  • wp_posts
  • wp_terms
  • wp_term_relationships
  • wp_term_taxonomy
  • wp_usermeta
  • wp_users



Question: How to hide the top admin bar at the frontend in WordPress?
Add following code functions.php
add_filter('show_admin_bar', '__return_false');



Question: How to hide Directory Browsing in WordPress from server?
Add following code in htaccess file
Options -Indexes



Question: How to display custom field in wordpress?
echo get_post_meta($post->ID, 'keyName', true); 



Question: How to run database Query in WordPress?
$wpdb->query("select * from $wpdb->posts   where ID>10 ");



Question: What types of hooks in wordpress is used?
1)Following are Actions hooks:.
has_action()
add_action()
do_action()
do_action_ref_array()
did_action()
remove_action()
remove_all_actions()

2)Following are Filters hooks .
has_filter()
add_filter()
apply_filters()
apply_filters_ref_array()
current_filter()
remove_filter()
remove_all_filters()



Question: How can you backup your WordPress content?
WordPress admin -> Tools -> Import



Question: List most commonly functions used in wordpress?
  • wp_nav_menu() :- Displays a navigation menu.
  • is_page() :- to check if this is page OR NOT, will return boolean value.
  • get_the_excerpt() :- Copy the excerpt of the post into a specified variable.
  • in_category() :- Check if the specified post is assigned to any of the specified categories OR not.
  • the_title():- Displays the title of the post in website.
  • the_content():- Displays the contents of the post in website.



Question: What are the file structure in wordpress.
Following are main files which used in wordpress
  • index.php :- for index page.
  • search.php :- For display the search result page.
  • single.php :- for single post page.
  • page.php :- display the static pages.
  • category.php :- Display the category page.
  • tag.php :- For display the tags page.
  • author.php :- For display author page.
  • taxonomy.php :- For display the taxonomy archive.
  • attachment.php :- For managing the single attachments page.
  • header.php :- For managing top part of page.
  • footer.php :- For manage bottom part of pages.
  • archive.php :- For archive page display.
  • 404.php :- For display 404 error page.

Wednesday, 10 December 2014

Htaccess RewriteRule Flags by Code Example

Htaccess RewriteRule Flags by Code Example

A RewriteRule can be modified by flag. Flags are included in square brackets at the end of the rule. We can also and multiple flags are separated by commas.

For Example:
[Flag1] //for 1 flag
[Flag1,Flag2] //for 2 flags
[Flag1,Flag2,Flag3 ] //for multiple flags

Following are most commonly htaccess flag:
1. htacces B(escape backreferences) Flag
Escape non-alphanumeric characters before applying the transformation


2. htaccess C(Chain) Flag
First htaccess Rule will be applied to next htaccess rule. Means if the rule matches, then control moves on to the next rule.


3. htaccess CO(Cookie) Flag
you can set a cookie when a particular RewriteRule matches
RewriteRule ^search/(.*)$ /search.php?term=$1[CO=variable:variableValue]
Set the variable=variableValue in cookie


4. htaccess DPI(discardpath) Flag
PATH_INFO portion of the rewritten URI to be discarded.


5. htaccess E (env) Flag
You can set the value of an environment variable. For example:
RewriteRule ^search/(.*)$ /search.php?term=$1[E=variable:variableValue]
Set the variable=variableValue in environment variable.


6. htaccess END Flag
This flag terminates not only the current round of rewrite but also prevents any subsequent rewrite from occurring in per-directory.


7. htaccess F(forbidden) Flag
This flag causes the server to return a 403 Forbidden status code to the client. For Example
RewriteRule \.exe - [F]
If anyone trying to open any file with .exe, he will get Forbidden error.



8. htaccess G(gone) Flag
This flag causes the server to return a 410 Gone status with the response code to the client. For Example
RewriteRule old_url - [G]
If old_url called, 410 gone status will be shown in the browser.



9. htaccess H(handler) Flag
This flag causes Forces the request to be handled with the specified handler. For example
RewriteRule !\. - [H=application/x-httpd-php]
Force all files without a file extension to be parsed by the php handler.



10. htaccess L(Last) Flag
This flag causes to stop processing the rule set, if the rule matches, no further rules will be processed.
RewriteRule ^(.*) /index.php?req=$1 [L]



11. htaccess N(Next) Flag
This flag causes ruleset to start over again from the top.
RewriteRule ^(.*) /index.php?req=$1 [N]


12. htaccess NC(nocase) Flag
This flag causes RewriteRule to be matched in a case-insensitive manner.
RewriteRule ^(.*) /index.php?req=$1 [NC]



13. htaccess NE(noescape) Flag
By default, special characters, such as & and ?, are converted to their hexcode equivalent. By Using NE flag prevents we can prevent this.


14. htaccess NS(nosubreq) Flag
This flag causes prevents the rule from being used on subrequests.



15. htaccess P(proxy) Flag
This flag causes the request to be handled by proxy request. For example, if you wanted all image requests to be handled by a image server
RewriteRule /(.*)\.(jpg|gif|png)$ http://images.mysite.com/$1.$2 [P]
Extension having jpg, gif, and png will be handled by images.mysite.com



16. htaccess PT(passthrough) Flag
This flag causes the result of the RewriteRule to be passed back through URL mapping.



17. htaccess QSA(qsappend) Flag
When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.

18. htaccess S(Skip) flag
htaccess S flag is used to skip rules that you don't want to run. The syntax of the skip flag is [S=N], where N means the number of rules to skip. For Example
# Does the file exist?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza.
RewriteRule .? - [S=3]

# IF the file exists, then:
    RewriteRule (.*\.gif) images.php?$1
    RewriteRule (.*\.html) docs.php?$1
    # Skip past the "else" stanza.
    RewriteRule .? - [S=1]
# ELSE...
    RewriteRule (.*) 404.php?file=$1
# END


19. htaccess T(type) flag
htaccess T flag cause sets the MIME type with which the resulting response will be sent. For Example
RewriteRule IMG - [T=image/jpg]


20. htaccess R(Redirect) flag
htacces R flag causes a HTTP redirect to be issued to the browser. Normally Redirect does not occur but if we use R Flag, then redirection will be happened to the browser. For Example
RewriteRule (.*\.gif) images.php?$1 [R]