Home › Forum › Problemi Vari con WP › Post recenti, da widget a pagina
Visualizzazione 1 filone di risposte
-
AutorePost
-
-
8 Febbraio 2014 alle 18:14 #26570ceradiniPartecipante
Salve a tutti, nel mio sito è presente anche un forum realizzato con phpBB e implementato con il plugin wp-united che mi mette a disposizione una serie di widget tra cui anche quello che riguarda i post recenti. Io ho a disposizione il codice php riguardante questo widget ma come faccio a inserirlo nella mia pagina home?
ho creato il template per la home ma adesso dovrei aggiustare il codice del widget in modo che funzioni anche in una pagina, qualcuno sa aiutarmi?
Ecco qui il codice (non è molto lungo):
class WPU_Latest_Phpbb_Posts_Widget extends WP_Widget {
public function __construct() {
global $phpbbForum;
$widget_ops = array('classname' => 'wp-united-latest-posts', 'description' => __('Shows the latest posts posted in the phpBB forum.', 'wp-united') );
$this->WP_Widget('wp-united-latest-posts', __('WP-United Latest Forum Posts', 'wp-united'), $widget_ops);
}
function widget($args, $instance) {
// prints the widget
extract($args, EXTR_SKIP);
$title = empty($instance) ? ' ' : apply_filters('widget_title', $instance);
$maxEntries = empty($instance) ? 25 : (int)$instance;
if ( !function_exists('wpu_latest_phpbb_posts') ) return false;
echo $before_widget;
echo $before_title . $title . $after_title;
echo '<ul class="wpulatestposts">';
wpu_latest_phpbb_posts('limit='.$maxEntries);
echo '' . $after_widget;
}
public function update($new_instance, $old_instance) {
//save the widget
$instance = $old_instance;
$instance = strip_tags(stripslashes($new_instance));
$instance = (int) strip_tags(stripslashes($new_instance));
return $instance;
}
public function form($instance) {
//widget form
$instance = wp_parse_args((array) $instance, array(
'title' => __('Recent Forum Posts', 'wp-united'),
'max' => 25
));
$title = strip_tags($instance);
$max = strip_tags($instance);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title: ', 'wp-united'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
<p><label for="<?php echo $this->get_field_id('max'); ?>"><?php _e('Maximum Entries: ', 'wp-united') ?> <input class="widefat" id="<?php echo $this->get_field_id('max'); ?>" maxlength="3" name="<?php echo $this->get_field_name('max'); ?>" type="text" value="<?php echo esc_attr($max); ?>" /></label></p>
<?php
}
}
Grazie a tutti dell'aiuto. -
8 Febbraio 2014 alle 18:29 #109617ceradiniPartecipante
Salve a tutti, ho risolto con un plugin che si chiama ‘Widgets on page’ che è fatto apposta per questo scopo. Ringrazio comunque per l’aiuto.
-
-
AutorePost
Visualizzazione 1 filone di risposte
- Devi essere connesso per rispondere a questo topic.