Pull the page excerpt content
Nov21

Pull the page excerpt content

Step 1: Open themefolder > includes > sidebar-init.php Step 2: In sidebar-init.php copy to “below code” under the // Widgetized sidebars register_sidebar(array('name' => 'Excerpt Widget','id' => 'excerpt-widget','description' => "Excerpt Widget", 'before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>')); Step 3: Go to template folder where to display “widget block” u can copy the below code <?php if ( is_active_sidebar('excerpt-widget') ) dynamic_sidebar('excerpt-widget'); ?> Step 4: Copy to widget file to plugins folder <?php /* Plugin Name:Excerpt Content Widget Plugin URI: http://www.webcenter.co.in Description: It display specified post in sidebar. Version: The Plugin's Version Number, e.g.: 1.0 Author: Anjani Author URI: http://www.webcenter.co.in */ // More Info #1 (Home) function excerptWidget() { $settings = get_option("widget_excerptwidget"); $title = $settings['title']; $page_ID_value = $settings['ID']; $linktext = $settings['linktext']; $link = $settings['link']; global $wpdb; $pages_info = $wpdb->get_results("SELECT * from $wpdb->posts WHERE post_status = 'publish' AND post_type='page' AND ID = ".$page_ID_value); if(count($pages_info)>0) { foreach ($pages_info as $fivesdraft) { ?><div class="excerpt-cont"> <h2><?php echo $title; ?><?php /*?><?php if ( $fivesdraft->post_title!="") echo $fivesdraft->post_title; ?><?php */?></h2> <?php //echo $fivesdraft->post_content; //echo $content = apply_filters('the_excerpt', $fivesdraft->post_content); $content = $fivesdraft->post_content; $excerpt_length = 45; $words = explode(' ', $content, $excerpt_length + 1); if(count($words) > $excerpt_length) : array_pop($words); array_push($words, '[...]'); $content = implode(' ', $words); endif; echo $content = '<p>' . $content . '</p>'; if ( $link !="" ) { ?> <p class="readmore"><a href="<?php echo $link; ?>" title="<?php echo $linktext; ?>"><?php echo $linktext; ?></a></p> </div> <?php } } } } function excerptWidgetAdmin() { $settings = get_option("widget_excerptwidget"); // check if anything's been sent if (isset($_POST['update_excerpt'])) { $settings['title'] = strip_tags(stripslashes($_POST['excerpt_title'])); $settings['ID'] = strip_tags(stripslashes($_POST['excerpt_ID'])); $settings['linktext'] = strip_tags(stripslashes($_POST['excerpt_linktext'])); $settings['link'] = strip_tags(stripslashes($_POST['excerpt_link'])); update_option("widget_excerptwidget",$settings); } echo '<p> <label for="excerpt_title">Title: <input id="excerpt_title" name="excerpt_title" type="text" class="widefat" value="'.$settings['title'].'" /></label></p>'; echo '<p> <label for="excerpt_ID">Page ID: <input id="excerpt_ID" name="excerpt_ID" type="text" class="widefat" value="'.$settings['ID'].'" /></label></p>'; echo '<p> <label for="excerpt_linktext">More Info Link Text: <input id="excerpt_linktext" name="excerpt_linktext" type="text" class="widefat" value="'.$settings['linktext'].'" /></label></p>'; echo '<p> <label for="excerpt_link">More Info Link URL: <input id="excerpt_link" name="excerpt_link" type="text" class="widefat" value="'.$settings['link'].'" /></label></p>'; echo '<input type="hidden" id="update_excerpt" name="update_excerpt" value="1" />'; } register_sidebar_widget('Excerpt Widget', 'excerptWidget'); register_widget_control('Excerpt Widget', 'excerptWidgetAdmin', 400, 200); ?> <div class="custom-widget"> <div class="tit"><?php echo $title; ?></div> <p><?php echo $content; ?></p> <div class="img"><img src="<?php bloginfo('stylesheet_directory'); ?><?php echo $imgsrc; ?>" /></div> <div class="more"><a href="<?php echo $link; ?>" title="<?php echo $linktext; ?>" ><?php echo $linktext; ?></a></div></div><?php } function customWidgetAdmin() { $settings = get_option("widget_custom"); // check if anything's been sent if (isset($_POST['update_custom'])) { $settings['title'] = strip_tags(stripslashes($_POST['custom_title'])); $settings['content'] = strip_tags(stripslashes($_POST['custom_content'])); $settings['imgsrc'] = strip_tags(stripslashes($_POST['custom_imgsrc'])); $settings['linktext'] = strip_tags(stripslashes($_POST['custom_linktext'])); $settings['link'] = strip_tags(stripslashes($_POST['custom_link'])); update_option("widget_custom",$settings); } echo '<p> <label for="custom_title">Title:</label> <input id="custom_title" name="custom_title" type="text" class="widefat" value="'.$settings['title'].'" /></p>'; echo '<p> <label for="custom_content">Content:</label> <textarea id="custom_content" name="custom_content" class="widefat">'.$settings['content'].'</textarea></p>'; echo '<p> <label for="custom_imgsrc">Image:</label> <input id="custom_imgsrc" name="custom_imgsrc" type="text" class="widefat" value="'.$settings['imgsrc'].'" /></p>'; echo '<p> <label for="custom_linktext">More Info Link Text:</label> <input id="custom_linktext" name="custom_linktext"...

Read More
Custom Options Widget
Nov21

Custom Options Widget

Step 1: Open themefolder > includes > sidebar-init.php Step 2: In sidebar-init.php copy to “below code” under the // Widgetized sidebars register_sidebar(array('name' => 'Custom','id' => 'custom','description' => "Custom Sidebar", 'before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>')); Step 3: Go to template folder where to display “widget block” u can copy the below code <?php if ( is_active_sidebar('custom') ) dynamic_sidebar('custom'); ?> Step 4: Copy to widget file to plugins folder <?php /* Plugin Name: Custom - Widget Plugin URI: http://www.webcenter.co.in Description: It display specified post in sidebar. Version: The Plugin's Version Number, e.g.: 1.0 Author: Webcenter Author URI: http://www.webcenter.co.in */ // More Info #1 (Home) function customWidget() { $settings = get_option("widget_custom"); $title = $settings['title']; $imgsrc = $settings['imgsrc']; $content = $settings['content']; $linktext = $settings['linktext']; $link = $settings['link']; global $wpdb; ?> <div class="custom-widget"> <div class="tit"><?php echo $title; ?></div> <p><?php echo $content; ?></p> <div class="img"><img src="<?php bloginfo('stylesheet_directory'); ?><?php echo $imgsrc; ?>" /></div> <div class="more"><a href="<?php echo $link; ?>" title="<?php echo $linktext; ?>" ><?php echo $linktext; ?></a></div></div><?php } function customWidgetAdmin() { $settings = get_option("widget_custom"); // check if anything's been sent if (isset($_POST['update_custom'])) { $settings['title'] = strip_tags(stripslashes($_POST['custom_title'])); $settings['content'] = strip_tags(stripslashes($_POST['custom_content'])); $settings['imgsrc'] = strip_tags(stripslashes($_POST['custom_imgsrc'])); $settings['linktext'] = strip_tags(stripslashes($_POST['custom_linktext'])); $settings['link'] = strip_tags(stripslashes($_POST['custom_link'])); update_option("widget_custom",$settings); } echo '<p> <label for="custom_title">Title:</label> <input id="custom_title" name="custom_title" type="text" class="widefat" value="'.$settings['title'].'" /></p>'; echo '<p> <label for="custom_content">Content:</label> <textarea id="custom_content" name="custom_content" class="widefat">'.$settings['content'].'</textarea></p>'; echo '<p> <label for="custom_imgsrc">Image:</label> <input id="custom_imgsrc" name="custom_imgsrc" type="text" class="widefat" value="'.$settings['imgsrc'].'" /></p>'; echo '<p> <label for="custom_linktext">More Info Link Text:</label> <input id="custom_linktext" name="custom_linktext" type="text" class="widefat" value="'.$settings['linktext'].'" /></p>'; echo '<p> <label for="custom_link">More Info Link URL:</label> <input id="custom_link" name="custom_link" type="text" class="widefat" value="'.$settings['link'].'" /></p>'; echo '<input type="hidden" id="update_custom" name="update_custom" value="1" />'; } register_sidebar_widget('Custom', 'customWidget'); register_widget_control('Custom', 'customWidgetAdmin', 400, 200); ?> Step 5: Activate plug in custom widget Step 6: Go to admin section Appearance > widgets > drag to ‘custom’ widget to custom block CSS code: .custom-widget{height: 351px;padding: 14px 13px 0;position: relative;text-align: center;width: 279px; background: #407297;border: 9px solid #E6E6E6;} .custom-widget .tit {color: #FFFFFF;font-family: 'Times New Roman';font-size: 34px;line-height: 37px;margin-bottom: 12px;} .custom-widget p {font-size: 19px;line-height: normal !important; font-family:"Times New Roman", Times, serif; margin-bottom:33px; color:#FFFFFF !important} .custom-widget .img { text-align:center;} .custom-widget .more{width:305px;} .custom-widget .more { position:absolute; bottom:6px; text-align:center; left:0; font-size:14px; font-weight:bold; text-transform:uppercase; font-family:Arial, Helvetica, sans-serif...

Read More
'