Пробовал что то менять, ничего не выходит.
Посмотрите пожалуйста:
PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- <?PHP
- class getlastnews extends WP_Widget {
- /** constructor -- name this the same as the class above */
- function getlastnews() {
- $this->WP_Widget( 'getlastnews_widget', __('Новости'), $widget_ops, $control_ops );
- }
- /** @see WP_Widget::widget -- do not rename this */
- function widget($args, $instance) {
- $cat_id = $instance['cat_id'];
- $number_entries = $instance['number_entries'];
- $lastnews = new WP_Query('cat=<?PHP echo $cat_id ?>&showposts=<?PHP echo $number_entries ?>&orderby=date');
- ?>
- <h2>Новости</h2>
- <div class="widget">
- <?PHP while ($lastnews->have_posts()) : $lastnews->the_post(); ?>
- <div class="news">
- <div class="clearly"><div>
- <div class="date_container"><span class="date"><?PHP the_time('d.m.Y'); ?></span></div>
- <div class="clearly"><div>
- <span class="txt_conteiner"><a href="<?PHP the_permalink() ?>" title="<?PHP the_title(); ?>">
- <?PHP the_title(); ?></a>
- </span>
- </div>
- <?PHP endwhile; ?>
- </div>
- <div class="clearly"><div>
- <?PHP
- }
- /** @see WP_Widget::update -- do not rename this */
- function update($new_instance, $old_instance) {
- $instance = $old_instance;
- return $instance;
- }
- /** @see WP_Widget::form -- do not rename this */
- function form($instance) {
- $cat_id = esc_attr($instance['cat_id']);
- $number_entries = esc_attr($instance['number_entries']);
- ?>
- <p>
- <label for="<?PHP echo $this->get_field_id('cat_id'); ?>"><?PHP _e('ID Рубрики:'); ?></label>
- <input class="widefat" id="<?PHP echo $this->get_field_id('cat_id'); ?>" name="<?PHP echo $this->get_field_name('cat_id'); ?>" type="text" value="<?PHP echo $cat_id; ?>" />
- </p>
- <p>
- <label for="<?PHP echo $this->get_field_id('number_entries'); ?>"><?PHP _e('Количество записей:'); ?></label>
- <input class="widefat" id="<?PHP echo $this->get_field_id('number_entries'); ?>" name="<?PHP echo $this->get_field_name('number_entries'); ?>" type="text" value="<?PHP echo $number_entries; ?>" />
- </p>
- <?PHP
- }
- } // end class example_widget
- ?>