Quantcast
Channel: Show Top 10 posts in a rss feed - WordPress Development Stack Exchange
Viewing all articles
Browse latest Browse all 2

Show Top 10 posts in a rss feed

$
0
0

I am trying to get a rss feed that will show the top 10 posts for the week. I am using the top 10 popular posts plugin to show them in a sidebar on the site which works great but need to show them in a rss so that I can have them send in a email that goes out. Below is some code for the top 10 API. Any help would be great.

<?php
/*
* This example fetches the popular posts tracked by Top 10. 
*
 */

if ( function_exists( 'get_tptn_pop_posts' ) ) {
$settings = array(
    'daily' => TRUE,
    'daily_range' => 30,
    'limit' => 20,
    'strict_limit' => FALSE,
  );
  $topposts = get_tptn_pop_posts( $settings ); // Array of posts

  $topposts = wp_list_pluck( (array) $topposts, 'postnumber' );

  $args = array(
    'post__in' => $topposts,
    'orderby' => 'post__in',
    'posts_per_page' => 7,
    'ignore_sticky_posts' => 1 
  );

  $my_query = new WP_Query( $args );
  if ( $my_query->have_posts() ) {
    while ( $my_query->have_posts() ) {
        $my_query->the_post();
        echo '<a href="' . get_permalink( get_the_ID() ) . '">';
        the_title();
        echo '</a>';
        wp_reset_postdata();
     }
  } else {
  }
  wp_reset_query();

  }

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images