WordPress Theme Development

  Home  Web Development  WordPress Theme Development


“WordPress Themes Development based Frequently Asked Questions by expert members with experience as WordPress Theme Developer. These questions and answers will help you strengthen your technical skills, prepare for the new job test and quickly revise the concepts”



109 WordPress Theme Development Questions And Answers

45⟩ Explain what are the types of hooks in WordPress and mention their functions?

There are two types of hooks

1) Action hooks

2) Filter hooks

Action Hooks :- Action hooks are points in wordpress core where its possible for outside resources to insert additional code.

For example- wp_head() , the_post(), get_sidebar() is an action hook which is used by most of themes. To hook an action, create an hook in your function file and hook it using add_action() function.

<?php

add_action( 'wp_head', 'head_func' );

function head_func () {

echo "<div>This is test</div>";

}

?>

Filter Hooks :- Filter hooks are used to handle output like using it you will add an text or content at end of content of your post. You will add an filter using add_filter() function. There are various filter used in wordpress as the_title(), wp_title(), get_the_excerpt(), get_to_ping(), attachment_icon().

For example:– Using these filter we will add content add end of posts.

<?php add_filter( 'the_content', 'webs_expert' );

function head_func( $content ) {

if ( is_single() ) {

$content .= '<div>This is test</div>' . " ";

}

return $content;

}

?>

 263 views

46⟩ Explain what are meta tags?

Meta tags keywords and description are used to display information about website or page.The commonly used meta tags are:-

☛ <meta name="resource-type" content="document" />

☛ <meta http-equiv="content-type" content="text/html; charset=US-ASCII" />

☛ <meta http-equiv="content-language" content="en-us" />

☛ <meta name="author" content="Muhammad" />

☛ <meta name="contact" content="" />

☛ <meta name="copyright" content="" />

☛ <meta name="description" content="" />

☛ <meta name="keywords" content="" />

 190 views

47⟩ Tell me why WordPress is better than blogger for blogging?

1. Customization and Flexibility

2. Hosting Opportunities

3. To customize the tiny image that people see in their address bar when they visit your blog, upload a blavatar.

4. The more tag allows you to display excerpts of your posts on your main posts page, instead of revealing the entire post.

5. To expand the text editor and hide the modules on the publishing screen, enable Distraction Free Writing.

6. Reproduce fully-functioning tweets — not just static screenshots of tweets — in posts, pages, and even comments with Twitter Embeds.

7. You can customize your post and page slugs, which can be handy when you want to create a URL that’s easier to remember (it’s also a good way to make posts search-friendly). Note that if you change a post slug, the old link will still work.

8. Reproduce fully-functioning tweets — not just static screenshots of tweets — in posts, pages, and even comments with Twitter Embeds.

 221 views

48⟩ Tell me will I have the ability to update my own content?

That depends on the site/project itself. We have created sites where almost every aspect could be edited by the client (content, navigation, photos, forms, etc) and others where it was a simple setup to allow for the main content areas to be edited. This is something we will discuss when planning the project and determine what your need will be. At the very least you will be able to edit the site content yourself and the ability to add/remove photos.

 204 views

49⟩ Tell me does the 644 permissions on wp-config.php compromise the username and password to all other users on my shared server?

This is a limitation of the way PHP is set up on your server. If you previously used MovableType, Perl was probably set up with suexec so Movable Type executed as your user. In this case, PHP is running as the web server user, which is why it has to be at least 444. There is phpsuexec but it seems many hosts don’t use it.

However this is often not an issue on modern shared hosts because even though the file is “world” readable each account is set up with a “jailshell” which keeps people locked in their home directory, and PHP can be easily modified with an open_basedir restriction to keep people from writing PHP scripts to read your files. If you are really concerned, you should contact your host to see what measures they are taking.

 254 views

50⟩ Tell me how do I disable comments?

First, unchecked Allow people to post comments on the article on the Options > Discussion panel. This will only disable comments on future posts. Now, to completely disable comments, you will have to edit each past post and uncheck Allow Comments from the Write Post SubPanel. Alternatively, you could run this MySQL query from the command line on a shell account or using phpMyAdmin: UPDATE wp_posts SET comment_status=”closed”;

If your goal is to permanently disable comments, then you should delete the wp-comments-post.phpfile as well.

 221 views

51⟩ Explain me what is XML-RPC?

Overview

XML-RPC is a Remote Procedure Calling protocol that works over the Internet.

An XML-RPC message is an HTTP-POST request. The body of the request is in XML. A procedure executes on the server and the value it returns is also formatted in XML.

Procedure parameters can be scalars, numbers, strings, dates, etc.; and can also be complex record and list structures.

Request example

☛ Here’s an example of an XML-RPC request:

☛ POST /RPC2 HTTP/1.0

☛ User-Agent: Frontier/5.1.2 (WinNT)

☛ Host: betty.userland.com

☛ Content-Type: text/xml

☛ Content-length: 181

☛ examples.getStateName 41

☛ Header requirements

The format of the URI in the first line of the header is not specified. For example, it could be empty, a single slash, if the server is only handling XML-RPC calls. However, if the server is handling a mix of incoming HTTP requests, we allow the URI to help route the request to the code that handles XML-RPC requests. (In the example, the URI is /RPC2, telling the server to route the request to the “RPC2″ responder.)

A User-Agent and Host must be specified.

The Content-Type is text/xml.

The Content-Length must be specified and must be correct.

Payload format

The payload is in XML, a single structure.

The must contain a sub-item, a string, containing the name of the method to be called. The string may only contain identifier characters, upper and lower-case A-Z, the numeric characters, 0-9, underscore, dot, colon and slash. It’s entirely up to the server to decide how to interpret the characters in a methodName.

For example, the methodName could be the name of a file containing a script that executes on an incoming request. It could be the name of a cell in a database table. Or it could be a path to a file contained within a hierarchy of folders and files.

If the procedure call has parameters, the must contain a sub-item. The sub-item can contain any number of s, each of which has a .

Scalar s

s can be scalars, type

 215 views

53⟩ Tell me how safe is website on WordPress?

The word press is safe to operate but still it is suggested to keep updating with the latest version of WordPress to avoid hacking. A WordPress Website is completely secure from any unauthorized access. However the error may occur due to downloading the Plug-in and Tools from an unauthorized resource.

 287 views

57⟩ Explain 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

 240 views

58⟩ Explain me 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:

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.

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()

 229 views

59⟩ Tell me how can I change what appears between Categories when I post in more than one Category?

To configure the way the post’s categories display, open the index.php file and find the line <div class meta>. There you will see the following code:

<?php the_category() ?>

Inside of the parentheses ( ) and quote marks, add or change this to reflect the new look you desire.

If you would like to have commas between the categories, the tag should read:

<?php the_category(‘,’) ?>

If you would like to have an arrow, the tag would look like this:

<?php the_category(‘ > ‘) ?>

If you would like to have a bullet, the tag would look like this:

<?php the_category(‘ • ‘) ?>

If you would like the “pipe” ( | ) between the categories, the tag would look like this:

<?php the_category(‘ | ‘) ?>

Use your imagination and creativity to make the separations in the categories look any way you like.

 220 views

60⟩ Please explain how can I hide my blog from people?

Whether you are testing a new version of WordPress, setting up a new blog or have some other reason to limit access, the following information may help you keep unwanted visitors out.

Apache

There is no guaranteed way to do this. You can use the .htaccess file (which also contains your permalink code) to check for certain IP addresses and prevent them from viewing your site. This will only stop the IP address, not the person, so if they have access to an allowed IP address, they can get to your page. One tutorial for this is located at rendc.org

An .htaccess file can also be used to prevent others from “hot-linking” to your images (bandwidth theft) or to set up a password protected blog.

Apache Basic Authentication

To require a password to access your site using .htaccess and .htpasswd: rendc.org.htpasswd.

Tools that help you create the files necessary to password protect your site: rendc.org.htaccess And .htpasswd Tools

Note: When your site is accessed the password is encoded weakly using Base64 and can be easily intercepted and decoded.

Windows IIS Basic Authentication

To require a password if your site is hosted on IIS, you can deselect Allow Anonymous Access and select Basic Authentication. You’ll also need to have a username with a password.

Note: When your site is accessed the password is encoded weakly using Base64 and can be easily intercepted and decoded.

 249 views