Viewing 7 replies - 16 through 22 (of 22 total)
  • Thread Starter d

    (@dsgnr)

    That’s done. Definitely made a visible change to all of the results shown

    Plugin Author Hector Cabrera

    (@hcabrera)

    Alright, we’re getting there. For some reason the wpp_get_mostpopular() also has the widget_id parameter set (probably a bug, will look into that later).

    Now please change the last bit into:

    // This is the sidebar widget, let's use the stock HTML output
    if ( isset($instance['widget_id']) ) {
        var_dump( $instance['widget_id'] );
        return $post_html;
    }
    Thread Starter d

    (@dsgnr)

    Ok I’ve added that in. Interesting that the sidebar is showing the same ID as the footer though

    Plugin Author Hector Cabrera

    (@hcabrera)

    Yes, it’s a bug. Just confirmed it.

    Alright, we’ll have to make a couple of minor modifications to the plugin to fix that:

    1. Go to Plugins > Editor and pick WordPress Popular Posts from the dropdown at the right.
    2. Find:
      // print popular posts list
      $shortcode_content .= $this->__get_popular_posts($shortcode_ops);

      … and change it to:

      // print popular posts list
      $shortcode_ops['sc'] = 1;
      $shortcode_content .= $this->__get_popular_posts($shortcode_ops);
    3. Next, find:
      // Pass the widget ID, might come in handy
      if ( isset($this->id) )
          $instance['widget_id'] = $this->id;

      … and change it to:

      if ( isset($this->id) && !isset($instance['sc']) )
          $instance['widget_id'] = $this->id;
    4. Hit the Update file button to apply changes.

    If everything went well, then the ID won’t be displayed and the wpp_get_mostpopular() template tag will use your custom HTML output. This is of course a temporary hack, I’ll make sure to properly fix it on the next version of the plugin.

    Thread Starter d

    (@dsgnr)

    Hi Hector,

    That works perfectly. Thank you very much. If you’d like me to create a PR on GitHub then let me know!

    One last thing then I promise I’ll leave you alone. On the homepage section, I’d like to limit it to a number of posts and to only show posts. Not pages. Is this possible with this configuration now?

    Thread Starter d

    (@dsgnr)

    Ah I got it now. I had to enter the parameters on the homepage. I’ve been so caught up in the functions.php Code That I forgot about the homepage template.

    Thank you for your help. If you want me to push the changes up to GitHub so you can just merge then let me know 🙂

    Plugin Author Hector Cabrera

    (@hcabrera)

    If you’d like me to create a PR on GitHub then let me know!

    Thank you, but please don’t bother with that for now. I’m currently refactoring the plugin and hopefully that hack won’t be necessary at all.

    On the homepage section, I’d like to limit it to a number of posts and to only show posts. Not pages. Is this possible with this configuration now?

    Yes, of course. The wpp_post filter hook only affects the HTML output of the plugin, the rest of the features will still work the same. You can still pass wpp_get_mostpopular() the post_type parameter to filter out pages:

    <?php
    if ( function_exists('wpp_get_mostpopular') ) {
    
        $args = array(
            'post_type' => 'post',
            'range' => 'all',
            'limit' => 4,
            'excerpt_by_words' => 1,
            'excerpt_length' => 55,
        	'stats_date' => 1
        );
    
        wpp_get_mostpopular( $args );
    
    }
    ?>
Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘Add author avatar to posts’ is closed to new replies.