WordPress: Top interview questions and answers

Posted on April 19, 2018 by Suresh Kamrushi in PHP

What is the use of function.php in WordPress
Every theme folder contains one and only one function.php. The purpose of this file is to allow theme developers to define theme features and functions. This file acts just like a WordPress plugin and can be used to add your own custom code snippets in WordPress. Updating your logo, copyright text, footer and header sections. Add custom widget, add new menu or submenu items, defining sidebars and their positions.
For additional information you can see :Click here

How many tables we have by default in WordPress?
If you install wordpress (4.1) it will create database with 11 tables. And by default tables are prefix with “wp_”.

Defining/creating your own plugins.
Official documentation link for creating custom plugin.

How you can connect WordPress from outside of wordprss installation?
To use wordpress function and class, first you need to load the wp instance and then use the function on that page. Below is the simple example of getting lastest post from Wrodpress.

<?php
    require_once('../blog/wp-load.php');
?>
<h2>Recent Posts</h2>
<ul>
<?php
    $recent_posts = wp_get_recent_posts(array(‘numberposts’=>3));
    foreach($recent_posts as $recent){
        echo '<li><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"] . '</a></li> ';
    }
?>
</ul>
Tagged as ,