WordPress FAQ

WordPress FAQ

Q. What are the types of hooks in WordPress
a. There are two types of hooks 1) Action hooks 2) Filter hooks

Q. What is custom field in wordpress?
a. Custom field is a meta-data that allows you to store arbitrary information to the wordpress post.

Q. What is the prefix of wordpress tables by default ?
a. By default, wp_ is the prefix for wordpress.

Q. What is WordPress Loop
a. To display post WordPress use PHP code, this code is known as loop.

Q. Why widget does not show up in the sidebar?
a. While using 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 forgot to save the changes in the widget or refreshing the older display of the page.

Q. What are meta-tags?
a. Meta-tags are keywords and description used to display website or page information.

Q. What are the reasons why one should not hack WordPress core file?
a. The best reason not to hack the core files is that whatever you might be doing has to be reworked as a patch.

Q. How to hide the top admin bar at the frontend in WordPress?
a. Add below line in function.php
add_filter('show_admin_bar', '__return_false');

Q. How to hide Directory Browsing in WordPress from server?
a. Add following code in htaccess file
Options -Indexes

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

Conditional Statement

Conditional Statement

Everybody knows how the Statement works in programing languages as PHP developed from C language lets directly go for sample programs.

We have 4 Conditional Statement in PHP they are

  1. Switch statement
  2. IF statement
    1. Simple If
    2. IF – else
    3. IF – elseIF – else
    4. Nested IF

Switch Statement:-

<?php

$X=”a”;

switch ($x)

{

Case “a”;

echo “A”;

break;

Case “B”;

echo “B”;

break;

Case “c”;

echo “C”;

break;

Default:

echo”D”;

}

?>

output will be

A

Control statements (or) Loops

  1. while loop
  2. do while loop
  3. for loop
  4. for each loop

While Loop:-

Write a program for to display the first 10 natural numbers ?

<?php

echo “The first 10 natural numbers are”.”<br>”;

$x=1;

while($x<=10)

{

Echo $x.”<br>”;

$x++;

}

?>

The first 10 natural numbers are

1

2

3

4

5

6

7

8

9

10

and now just check the below program what will be the out put.

<?php

$x=1;

while($x++<=5);

echo $x.”<br>”;

?>

predict what will be the output of the Program ????

Output will be

7

Excersises

  1. Write a program to to display first 10 even numbers ?
  2. Write a program to to display the multiplication table as shown below ?

    5 * 1 = 55 * 2 = 10

    upto

    5 * 10 = 50

  3. Write a program to to display odd numbers between x and y ?
  4. Write a program to to display to display reverse of a number ?

    ex: if we taken input “1234” the out has to be “4321”

  5. Write a program to to display numbers in words ?

    ex: if we taken number as “1234” the out has to be “ one two three four”