plugin-icon

WP Most Popular

제작자: MattGeri·
WP Most Popular is a simple plugin which tracks your most popular blog posts based on views and lets you display them in your theme or blog sidebar.
등급
4.9/5
버전
0.3.1
활성화된 설치 항목
2K
최근 업데이트일
Aug 7, 2018
WP Most Popular

WP Most Popular was born out of frustration in finding a decent plugin which performs one simple task and that is to rank your most popular blog posts.

The plugin keeps a log of your most popular posts based on views and lets you display them in your blog theme with custom styling. You can display popular posts from the last day, 7 days, 30 days or all time.

It also comes with a sidebar widget to let you display your popular posts on your blogs sidebar.

If you are a developer and integrate the plugin in to a theme, you will get a lot more flexibility out of the plugin including the ability to show the most popular custom post types etc.

This plugin was built and is maintained by WP Geeks. For extra documentation, videos, snippets and support, visit the WP Most Popular product page.

Usage

There are two ways in which you can use this plugin.

  1. As a sidebar widget
  2. Custom function in your theme files

Using the widget is the easiest way and recommended for most users. If you are a developer and want to integrate the plugin in to your existing theme, then read the information below.

Firstly, the main function which you will need to include in your theme to fetch the popular posts is called wp_most_popular_get_popular().

You can pass that function the following parameters in array form:

  • limit (integer)
    • The number of posts you would like to display i.e. 5
    • Default: 5
  • post_type (string) / (array)
    • The post type you would like to display
    • Example: post
    • Default: All post types
  • range (string)
    • In what date range would you like to display popular posts in
    • Accepted: all_time, monthly, weekly, daily
    • Default: all_time

Those are the current parameters that the plugin supports. Let’s look at an example of how to display the most recent popular posts in a unordered list.

<?php echo '<ul>'; $posts = wp_most_popular_get_popular( array( 'limit' => 10, 'post_type' => 'post', 'range' => 'all_time' ) ); global $post; if ( count( $posts ) > 0 ): foreach ( $posts as $post ): setup_postdata( $post ); ?> <li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a></li> <?php endforeach; endif; echo '</ul>'; ?>

필터

The following filters are available to you:

  • wp_most_popular_list_before – used to filter the
    element of the outputted widget list * **wp_most_popular_list_after** – used to filter the

element of the outputted widget list * wp_most_popular_list_item_single – filters for a the list item generated by the widget

작업

  • wp_most_popular_list_item – used for modifying the list output
무료Business 요금제에서
설치하면 WordPress.com 서비스 약관서드파티 플러그인 약관에 동의하게 됩니다.
테스트된 버전
WordPress 4.9.28
이 플러그인은 다운로드할 수 있으며 에서 사용할 수 있습니다.