Filter Search In WordPress

We can filter our search in WordPress according to posts or custom post. Like I have two custom posts type videos and news and I want WordPress search page will display records out of only these 2 custom posts whenever user search record. So to achieve this we have to write this code in our […]

Disable Updates in WordPress

To disable the update in WordPress Write these lines in functions.php of your theme folder. To Disable Theme Updates # 3.0+ remove_action( ‘load-update-core.php’, ‘wp_update_themes’ ); add_filter( ‘pre_site_transient_update_themes’, create_function( ‘$a’, “return null;” ) ); wp_clear_scheduled_hook( ‘wp_update_themes’ );

document.getElementsByName

getElementsByName() is a method in JavaScript through which we can accesses all elements with the specified name. Example : <html> <head> <script type=”text/javascript”> function getbyNameDemo(){ var sub = document.getElementsByName(‘rbtnSubjects’);

Textbox in CakePHP

Following are the methods through which we can create Textbox in CakePHP. Example 1: echo $this->Form->input(‘usrUsername’); Above code will render following output in view: <div class=”input text”> <label for=”UserUsrUsername”>Usr Username</label><input name=”data[User][usrUsername]” type=”text” id=”UserUsrUsername”/> </div>

Custom Post in WordPress

In below example I have added 2 custom posts in WordPress (with different parameters) Videos News Add the following code in functions.php and it will create menu in admin panel for videos and news. add_action( ‘init’, ‘create_post_type’ ); function create_post_type() { register_post_type( ‘my_video’, array( ‘labels’ => array( ‘name’ => __( ‘Videos’ ), ‘singular_name’ => __( […]

Create a Form in CakePHP

To create a form in CakePHP we can use careate() method. Let’s take an example with cake1 as a root folder and users is a table. <?php echo $this->Form->create(); ?> Above code will render following output in view: <form action=”/cake1/users/” id=”UserIndexForm” method=”post” accept-charset=”utf-8″> In create function parameters are optional. If we call this function without […]

document.getElementById

getElementById is a function in JavaScript to access the HTML elements. It’s a function of document object and can only access by using document.getElementById. Example : <html> <script> function sum() { var num1 = document.getElementById(‘num1’); var num2 = document.getElementById(‘num2’); var res = document.getElementById(‘result’); res.value = parseInt(num1.value) + parseInt(num2.value); } </script> <body> Enter First Number : […]

The Global Keyword

A global variable can be accessed in any part of the program. In php global keyword is used to access a global variable. Global keyword has to use before the variables (inside the function). Global variables are stored in an array called $GLOBALS[index]. Index holds the name of variable and this array can directly access […]

Array in JavaScript

Array is use to store multiple values in a one variable. Example 1: <script> var a = new Array(); a[0] = 2; alert(a[0]); </script> Example 2: <script> var b = new Array(78,4,5,3,5,7); for(i=0; i < b.length; i++) { alert(b[i]); } </script> Example 3: <script type=”text/javascript”> var ar = new Array(“Ram”,”Deep”,”Ravi”,”Mohit”); for (i=0; i

Popups in javascript

There are three kinds of popup boxes in JavaScript Who to define array in php? Alert box Alert box display message with ok button Example: <html> <script> alert(“Hello Viewers”); </script> </html> Confirm box Confirm box display message with ok and cancel button, it is use to take user confirmation. If we click ok, it returns […]