Forums

[resolved] [Plugin: Yet Another Related Posts Plugin] Widget cannot be used in different sidebars (9 posts)

  1. gtk_
    Member
    Posted 2 years ago #

    Widget cannot be used in different sidebars, for example
    if we have two sidebars, it can be used only once.

    I am trying to fix this myself, could be usefull to others too.
    Cheers.

  2. Thanks. I'm not sure why this is, either, and would love to know if you work it out.

  3. gtk_
    Member
    Posted 2 years ago #

    To fix this remove completely function widget_yarpp_init()
    from includes.php, also the line add_action('plugins_loaded', 'widget_yarpp_init'); from yarpp.php

    Instead of widget_yarpp_init() place this code, and the plugin will be
    working with multiple sidebars:

    class YarppWidget extends WP_Widget {
        /** constructor */
        function YarppWidget() {
            parent::WP_Widget(false, $name = 'YARPP Widget');
        }
    
        /** @see WP_Widget::widget */
        function widget($args, $instance) {
     		extract($args);
    		global $wpdb, $post;
    		if (is_single() && have_posts()) {
    		  get_post($post->ID);
    		  echo $before_widget;
    		  echo $before_title . __('Related Posts','yarpp') . $after_title;
    		  echo yarpp_related(array('post'),array());
    		  echo $after_widget;
     		}
         }
    
        /** @see WP_Widget::update */
        function update($new_instance, $old_instance) {
            return $new_instance;
        }
    
        /** @see WP_Widget::form */
        function form($instance) {
            $title = esc_attr($instance['title']);
         }
    
    } // class YarppWidget
    
    add_action('widgets_init', create_function('', 'return register_widget("YarppWidget");'));

    Regards,
    George

  4. William Bowles
    Member
    Posted 2 years ago #

    Not sure where to leave this but it might as well be here.

    When I first installed YARRP way back. it screwed a lot of things up even though when it worked, it worked the best. But I had to take out of service.

    Then this new version came along so I installed it on two sites and had to take it down as it stopped all the posts and pages from being displayed.

    Sidebar, worked fine.

    Bill

  5. gtk_
    Member
    Posted 2 years ago #

    I suggest you create .htaccess file if you don't have already one
    on your server root and place on the first line:

    php_flag display_errors on

    Tell us what error shows and will tell you how to fix it ;)

    George

  6. William Bowles
    Member
    Posted 2 years ago #

    Yes, I have .htaccess installed, I'll try it and let you know.

    Thanks

    Bill

  7. @gtk_, what's the salient difference in that patch you've supplied? What makes that work with multiple, but not the supplied code?

  8. William Bowles
    Member
    Posted 2 years ago #

    Ok, I've installed it in .htaccess, now what?

    B

  9. @Creative-i are you seeing any PHP errors being printed now?

Topic Closed

This topic has been closed to new replies.

About this Topic