Wordpress Archive
Steps for how to add Dynamic Sidebar in WordPress:- 1. Register sidebar in function.php as other sidebar registered, we can copy and past the as given in function.php for other sidebars. 2. Call on page:- dynamic_sidebar(‘sidebar-4’);
get_permalink() is a function in WordPress through which we can get the link of post or page. This function is helpful when we are customizing our posts or page. For Ex. I have called all the post whose category id is 3 on page and want to display a link of detail page of the
@ is use to avoid the warning. Example :- when we use session_start(), some time it will display the error “Warning: Cannot modify header information – headers already sent by” to avoid this warning we can start session like :- @session_start();
How to change date format in php? we can display date in different formats in php as given:- $dt = “2001/02/02”; echo date(‘d M Y’, strtotime($dt)); Output:- 02 Feb 2001 $dt = “2001/02/02”; echo date(‘M d Y’, strtotime($dt)); Output:- Feb 02 2001
Generally we store date of birth in our database and in front end we have to display age also. In php we can use following code to calculate AGE out of date of birth. $dateofbirth = “12/08/1984”; echo floor((time() – strtotime($dateofbirth))/31556926); Any question please write in comments.
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’ => __(
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’ );
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
We can change the design and add additional fundability in the search widget provided by WordPress. Make a file “searchform.php“ in your theme folder and add the blow given code. You can also add your style or script as need in this file. <?php /** * The template for displaying Search Results pages * *