WordPress Interview Questions & Answers – Part7

61. What is the Basic Difference Between Posts vs. Pages.
Posts are timely vs. Pages are timeless.
Posts are social vs. Pages are NOT.
Posts can be categorized vs. Pages are hierarchical.
Posts are included in RSS feed vs. Pages are not.
Pages have custom template feature vs. Posts do not.

 62. What is child theme? Why we used it?
A WordPress child theme is a WordPress theme that inherits its functionality from its parent WordPress theme.Child themes are often used when you want to customize or tweak an existing WordPress theme without losing the ability to upgrade that theme.
Advantage is child theme is Safe Updates,Easy to Extend,Fallback Safe

 63.  How to hide Directory Browsing in WordPress from server using .htaccess file?
By default when your web server does not find an index file (i.e. a file like index.php or index.html), it automatically displays an index page showing the contents of the directory.SO now if you want to hide this add below code in .htaccess file.

Options -Indexes

64. What is hooks and types of hooks in wordpress?
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:

  1. Actions: Actions 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 are executed at these points, using the Action API.
  2. Filters: Filters 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 is 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()

65. How do I prevent my images from being hot-linked by another website?
You can use your .htaccess file to protect images from being hot linked, or, in other words, being linked-to from other websites. This can be a drain on your bandwidth, because if someone links directly to the image on your site, then you lose the bandwidth.

66. How do I redirect users back to my blog’s main page after they login?
By default, WordPress reroutes a registered user to the Administration Panels after they log into the blog. To change the page, there are WordPress Plugins that can handle the redirect, or you can set the Theme function to handle it. See Function_Reference/wp_login_url.

67. What are the custom fields in wordpress? How to display it?
We will add extra information to our post by using custom fields.Custom Fields are a form of meta-data that allows us to store arbitrary information with each WordPress post.
To display the Custom Fields for each post, use the the_meta() template tag.
To fetch meta values use the get_post_meta() function.
For example we use custom fields:-

<?php echo get_post_meta($post->ID, ‘key’, true); ?>

68. In PHP, what are magic methods and how are they used?

PHP functions that start with a double underscore – a “__” – are called magic functions (and/or methods) in PHP. They are functions that are always defined inside classes, and are not stand-alone (outside of classes) functions. The magic functions available in PHP are: __construct(), __destruct(), __call(), __callStatic(), __get(), __set(), __isset(), __unset(), __sleep(), __wakeup(), __toString(), __invoke(), __set_state(), __clone(), and __autoload().

69. How to run database Query in WordPress?
The $wpdb->query function allows you to execute any SQL query on the WordPress database. It is best to use a more specific function. Check sample code below for SELECT query.

<?php $wpdb->query('query'); ?>// Examples

$wpdb->query(    "

UPDATE $wpdb->posts

SET post_parent = 7


AND post_status = 'static'    "


70. How to hide the top admin bar at the frontend of wordpress 3.4?
Add the below mentioned code in the theme(active) function.php

add_filter(‘show_admin_bar’, ‘__return_false’);


Add the below code in the active theme stylesheet

#wpadminbar {

display: none; visibility: hidden;

Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

Your email address will not be published. Required fields are marked *

9 − two =

Popup Dialog Box Powered By : XYZScripts.com
  • RSS
  • Facebook
  • Google+
  • Twitter