• Resolved max07min

    (@max07min)


    Excellent for show popular in homepage

    but how to show Popular posts per Category for any single page and archive page that appropriate

    • This topic was modified 7 years, 2 months ago by max07min.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hey there,

    If you want to display different lists of popular posts by category on a page, you can use the [wpp] shortcode in conjuction with the cat parameter (see Settings > WordPress Popular Posts > Parameters for more).

    Similarly, if you want to display a list of popular posts by category when archive.php is loaded by WordPress, you can use the wpp_get_mostpopular() template tag in conjunction with the cat parameter. For example:

    <?php
    
    // Somewhere inside your archive.php template ...
    
    if ( function_exists('wpp_get_mostpopular') ) {
    
        // WPP parameters
        $args = array(
            'range' => 'weekly'
        );
    
        // Get the category ID so we can use it with the wpp_get_mostpopular() template tag
        if ( is_category() ) {
            $args['cat'] = get_queried_object_id();
        }
    
        wpp_get_mostpopular( $args );
    
    }
    
    ?>
    • This reply was modified 7 years, 2 months ago by Hector Cabrera. Reason: Wrapped code in backticks
    • This reply was modified 7 years, 2 months ago by Hector Cabrera. Reason: Added link to wpp_get_mostpopular() function documentation
Viewing 1 replies (of 1 total)
  • The topic ‘Popular per Category’ is closed to new replies.