Hello,
I would like to define a customized rss widget (that people can't edit : they can just drag & drop it) : for example :
the widget called News actually shows let's say 10 items of the news from BBC.
how could I do that ?
Hello,
I would like to define a customized rss widget (that people can't edit : they can just drag & drop it) : for example :
the widget called News actually shows let's say 10 items of the news from BBC.
how could I do that ?
copy the normal rss widget...
replace the url variable with ur url and remove the widget options code...
Yep, but it's not that easy unfortunately :(
Here is what i've done. But nothing appears.
Thanks for your help
///hack
function wp_widget_rss($args, $number = 1) {
require_once(ABSPATH . WPINC . '/rss.php');
extract($args);
$num_items = 10;
if ( empty($num_items) || $num_items < 1 || $num_items > 10 ) $num_items = 10;
$url = "http://www.lesoir.be/services/rss/belgique/index.xml";
$rss = fetch_rss($url);
$link = clean_url(strip_tags($rss->channel['link']));
while ( strstr($link, 'http') != $link )
$link = substr($link, 1);
$desc = attribute_escape(strip_tags(html_entity_decode($rss->channel['description'], ENT_QUOTES)));
$title = 'lesoir';
if ( empty($title) )
$title = htmlentities(strip_tags($rss->channel['title']));
if ( empty($title) )
$title = $desc;
if ( empty($title) )
$title = __('Unknown Feed');
$url = clean_url(strip_tags($url));
if ( file_exists(dirname(__FILE__) . '/rss.png') )
$icon = str_replace(ABSPATH, get_option('siteurl').'/', dirname(__FILE__)) . '/rss.png';
else
$icon = get_option('siteurl').'/wp-includes/images/rss.png';
$title = "<a class='rsswidget' href='$url' title='" . attribute_escape(__('Syndicate this content')) ."'><img style='background:orange;color:white;border:none;' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>";
?>
<?php echo $before_widget; ?>
<?php $title ? print($before_title . $title . $after_title) : null; ?>
<?php
if ( is_array( $rss->items ) && !empty( $rss->items ) ) {
$rss->items = array_slice($rss->items, 0, $num_items);
echo '<ul>';
foreach ($rss->items as $item ) {
while ( strstr($item['link'], 'http') != $item['link'] )
$item['link'] = substr($item['link'], 1);
$link = clean_url(strip_tags($item['link']));
$title = attribute_escape(strip_tags($item['title']));
if ( empty($title) )
$title = __('Untitled');
$desc = '';
if ( $show_summary ) {
$summary = '<div class="rssSummary">' . $item['description'] . '</div>';
} else {
if ( isset( $item['description'] ) && is_string( $item['description'] ) )
$desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
$summary = '';
}
echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>$summary</li>";
}
echo '</ul>';
} else {
echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';
}
echo $after_widget;
}
// fin du hack
Cher enseignement,
Il faut déclarer le widget afin qu'il soit pris en compte.
Sur ce code, il manque la partie "administration" du widget et la déclaration du widget, faut de quoi, il ne sera pas reconnu comme widget!
Veuillez prendre inspiration dans les widgets existant pour comprendre le fonctionnement, ou aller directement se documenter à cette adresse.
I've tried this but it did not work
...
Any idea ?
register_sidebar_widget('rss-Enseignement', 'wp_widget_rss');
A widget named "wp_widget_rss" already exist in core(wp-incudes/widgets.php). To register a new widget, it would need a new name.
I've tried with a new name wp_widget_rss_enseignement and the same name in "function"
but it fails
"but it fails"
scratch, scratch, scratch.
I don't even see why an RSS Widget is needed - an RSS widget is built into the wordpress core....
http://www.computer-fix.net/how-to/display-an-rss-feed-in-wordpress-without-plugins/
Why not just build an empty widget (see original google search one for example) and parse the actual RSS feed in it?