WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_widget_recent_entries deprecated in widgets.php? (7 posts)

  1. jzahlaway
    Member
    Posted 5 years ago #

    In 2.7, in the file includes/widgets.php, one could modify the wp_widget_recent_entries function such that the Recent Posts widget would exclude certain categories.

    In 2.8, wp_widget_recent_entries is now deprecated. How, then, do I exclude certain categories from the Recent Posts widget?

  2. OlafB
    Member
    Posted 5 years ago #

    Hi jzahlaway,
    I have the same problem. I copyed the functions (wp_widget_recent_entries and wp_widget_recent_comments) from the 2.7 in widgets.php from 2.8.1 and is works.

    Better solution are wellcome :)

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    All the widgets moved to default_widgets.php. WP_Widget_Recent_Posts is a new class that takes the place of that old function.

  4. OlafB
    Member
    Posted 5 years ago #

    Hm, thanks Otto42, i have in the footer.php

    $recentParamEntry = array('number'=>'5', 'before_title'=>'<h3>', 'after_title'=>'</h3>', 'before_widget'=>'<div>', 'after_widget'=>'</div>');
    wp_widget_recent_entries($recentParamEntry);

    change to

    $recentParamEntry = array('number'=>'5', 'before_title'=>'<h3>', 'after_title'=>'</h3>', 'before_widget'=>'<div>', 'after_widget'=>'</div>');
    WP_Widget_Recent_Posts($recentParamEntry);

    give me:

    Fatal error: Call to undefined function WP_Widget_Recent_Posts() in ......./wp-content/themes/home/footer.php on line 38

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    It's a class, not a function. You can't call it like that.

  6. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    Try something more like this:

    $instance = array("title" => "My Widget", "number" => 5);
    $args = array("title" => "My Widget", 'before_title'=>'<h3>', 'after_title'=>'</h3>', 'before_widget'=>'<div>', 'after_widget'=>'</div>');
    $sb = new WP_Widget_Recent_Posts();
    $sb->number = $instance['number'];
    $sb->widget($args,$instance);
  7. OlafB
    Member
    Posted 5 years ago #

    Ah fein, 1000x thank you. All problems solved, great!!!

Topic Closed

This topic has been closed to new replies.

About this Topic