Código PHP:
<?php
/*
* Plugin Name: Featured Posts Widget
* Plugin URI: http://rubiqube.com
* Description: A widget to display a featured posts carousel
* Version: 1.0
* Author: Adrian Diaconescu
* Author URI: http://rubiqube.com
*/
/*
* tabd function to widgets_init that'll lotab our widget.
*/
add_action( 'widgets_init', 'rbq_featured_widget' );
/*
* Register widget.
*/
function rbq_featured_widget() {
register_widget('RBQ_Featured_Widget');
}
/*
* Widget class.
*/
class rbq_featured_widget extends WP_Widget {
/* ---------------------------- */
/* ------- Widget setup ------- */
/* ---------------------------- */
function RBQ_Featured_Widget() {
/* Widget settings */
$widget_ops = array( 'classname' => 'rbq_featured_widget', 'description' => __('A widget to display a featured posts carousel.', 'rbq-domain') );
/* Widget control settings */
$control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'rbq_featured_widget' );
/* Create the widget */
$this->WP_Widget( 'rbq_featured_widget', __('Featured Posts', 'rbq-domain'), $widget_ops, $control_ops );
}
/* ---------------------------- */
/* ------- Display Widget -------- */
/* ---------------------------- */
function widget( $args, $instance ) {
global $wpdb;
extract( $args );
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title'] );
/* Before widget (defined by themes). */
echo $before_widget;
/* Display the widget title if one was input (before and after defined by themes). */
if ( $title )
echo $before_title . $title . '<span><a href="#" id="carousel-vert-prev">«</a><a href="#" id="carousel-vert-next">»</a></span>' . $after_title;
?>
<ul id="carousel-vert" class="jcarousel-skin">
<?php
query_posts(array('orderby' => 'rand', 'showposts' => 8));
if (have_posts()) :
while (have_posts()) : the_post();
?>
<li>
<a class="pimage" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
<p class="pcat"><?php the_category(', '); ?></p>
<p class="ptitle"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p>
<p class="meta"><?php the_time('j / F / Y') ?> - <?php if(function_exists('the_views')) { the_views(); } ?></p>
</li>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
</ul>
<?php
/* After widget (defined by themes). */
echo $after_widget;
}
/* ---------------------------- */
/* ------- Update Widget -------- */
/* ---------------------------- */
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
/* Strip tags to remove HTML (important for text inputs). */
$instance['title'] = strip_tags( $new_instance['title'] );
return $instance;
}
/* ---------------------------- */
/* ------- Widget Settings ------- */
/* ---------------------------- */
/**
* Displays the widget settings controls on the widget panel.
* Make use of the get_field_id() and get_field_name() function
* when creating your form elements. This handles the confusing stuff.
*/
function form( $instance ) {
/* Set up some default widget settings. */
$defaults = array(
'title' => 'Featured Posts'
);
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
<!-- Widget Title: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'rbq-domain') ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
</p>
<p><?php _e('Make sure you fill out the featured post IDs under Appearance > Theme Options', 'rbq-domain'); ?></p>
<?php
}
}
?>
Qué pasa?, yo quiero agregarle al lado del titulo esto:
<span class="TeGusto"></span>
Pero no sé donde, trato de agregarlo pero la linea me sale en rojo.
Ese span muestra una pequeña foto 24x24, un ejemplo de lo que quiero hacer aqui:
http://www.oyeeso.com/?s=mmg
Sale la imagen de una estrella al lado del titulo.
Podrian ayudarme a agregarlo en ese archivo, no logro lograrlo!