Category Archives: Wordpress

WordPress widget to display content on specified pages

Follow the steps given below to use this widget
  • Paste code on a file and save it inside folder
  • Place this folder in /wp-content/plugins/
  • Activate it using the menu plugins
  • Drag the widget to the sidebar
  • Fill the form and save the values .
  • The content you entered will be displayed on given pages(based on the page value)
  • If no value is entered for the field page url , it will show up on all pages


<br /> <?php /** * Plugin Name:MindText * Plugin URI: http://tppramod.wordpress.com/ * Description: A widget that displays content on specified pages * Version: 0.1 * Author: MindLabs Systems Pvt Ltd * Author URI: Pramod T P */ add_action( 'widgets_init', 'mind_text_widgets' ); function mind_text_widgets() { register_widget( 'mindWidget' ); } class mindWidget extends WP_Widget { function mindWidget() { $widget_ops = array( 'classname' => 'mindClass', 'description' => __('A widget that displays content on specified pages.', 'mindClass') );<br /> $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' );<br /> $this->WP_Widget( 'example-widget', __('mindText', ''), $widget_ops, $control_ops );<br /> }</p> <p> function widget( $args, $instance ) {<br /> extract( $args );<br /> $title = apply_filters('widget_title', $instance['title'] );<br /> $pageText = $instance['pageText'];<br /> $pageTitle = $instance['pageTitle'];<br /> $urlArray = array_filter(explode("/",$_SERVER['REQUEST_URI']));</p> <p> if(end($urlArray)==$title or empty($title)) {<br /> echo "<br />".$pageTitle."<br />";<br /> echo nl2br($pageText);<br /> }</p> <p> /*echo ($pageText);*/<br /> }</p> <p> function update( $new_instance, $old_instance ) {<br /> $instance = $old_instance;</p> <p> $instance['title'] = strip_tags( $new_instance['title'] );<br /> $instance['pageText'] = $new_instance['pageText'] ;<br /> $instance['pageTitle'] = $new_instance['pageTitle'] ;</p> <p> return $instance;<br /> }</p> <p> function form( $instance ) {</p> <p> $instance = wp_parse_args( (array) $instance, $defaults ); ?></p> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Page URL (Target by URL)', 'mindclass'); ?></label><br /> <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:95%; border:1px solid #ccc" _mce_style="width: 95%; border: 1px solid #ccc;" /> </p> <p> <label for="<?php echo $this->get_field_id( 'pageTitle' ); ?>"><?php _e('Title:', 'mindclass'); ?></label><br /> <input id="<?php echo $this->get_field_id( 'pageTitle' ); ?>" name="<?php echo $this->get_field_name( 'pageTitle' ); ?>" value="<?php echo $instance['pageTitle']; ?>" style="width:95%; border:1px solid #ccc" _mce_style="width: 95%; border: 1px solid #ccc;" /> </p> <p> <label for="<?php echo $this->get_field_id( 'pageText' ); ?>"><?php _e('Text:', 'mindclass'); ?></label><br /> <textarea id="<?php echo $this->get_field_id( 'pageText' ); ?>" name="<?php echo $this->get_field_name( 'pageText' ); ?>" style="width:98%; height:200px;" _mce_style="width: 98%; height: 200px;"><?php echo $instance['pageText']; ?>

bloginfo function and its parameters

name = Testpilot .
description = Just another WordPress blog .
admin_email = admin@example .
comments_rss2_url = http://example/home/comments/feed .
charset = UTF-8 .
html_type = text/html .
language = en-US .
text_direction = ltr .
version = 2.9.2 .