Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- /*
- Plugin Name: Featured Resources
- Plugin URI: http://wpguru.in
- Description: Featured resources widget for WPGuru.in
- Author: Rakesh Raja
- Version: 1.0
- Author URI: http://wpguru.in
- */
- class FeaturedResources extends WP_Widget
- {
- function FeaturedResources()
- {
- $widget_ops = array('classname' => 'fearesources', 'description' => 'Featured Resources' );
- $this->WP_Widget('FeaturedResources', 'Featured Resources', $widget_ops);
- }
- function form($instance)
- {
- $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
- $title = $instance['title'];
- ?>
- <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
- <?php
- }
- function update($new_instance, $old_instance)
- {
- $instance = $old_instance;
- $instance['title'] = $new_instance['title'];
- return $instance;
- }
- function widget($args, $instance)
- {
- extract($args, EXTR_SKIP);
- echo $before_widget;
- $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
- if (!empty($title))
- echo $before_title . $title . $after_title;;
- // WIDGET CODE GOES HERE ?>
- <!--resource post-->
- <div class="sposts">
- <?php
- $args = array( 'post_type' => 'resource');
- $loop = new WP_Query( $args );
- while ( $loop->have_posts()) : $loop->the_post();
- if (get_field('featured') == "yes" ) {
- echo '<a href="';
- the_permalink();
- echo '"><div class="spost"><h2>';
- the_title();
- echo '</h2><div class="left"><img src="';
- the_field('thumb');
- echo'" alt=""></div><div class="right">';
- echo content('100');
- echo'<span>Click here to go to read more... </span></div>';
- echo'<div style="clear:both;"></div></div></a>';
- }
- endwhile;
- ?>
- </div>
- <!--resource post-->
- <?php echo $after_widget;
- }
- }
- add_action( 'widgets_init', create_function('', 'return register_widget("FeaturedResources");') );?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement