F2P Shortcode: How to Display a List of Feed Sources

In order to display a list of feed sources on a particular page, listing the feed source’s name and URL, you can use the filter below. 

Once you have added the code, insert this shortcode –  [wprss_custom_feed_listing] – on any page to show the list of feed sources with their respective links.

add_shortcode('wprss_custom_feed_listing','wprss_feed_source_listing');
    function wprss_feed_source_listing(){
        $query_args = Array(
                'post_type' => 'wprss_feed',
                'posts_per_page' => -1
                );
        $query = new WP_Query($query_args);


        if( $query->have_posts() ){
            echo '<ul>';
            while($query->have_posts()){
                $query->the_post();
                $feed_url = get_post_meta( get_the_ID(), 'wprss_url', true );
                echo '<li>'.get_the_title().' - <a href="'.$feed_url.'">'.$feed_url.'</a>';
            }
            echo '</ul>';
        }
        wp_reset_query();
        wp_reset_postdata();
    }

How do I add this to my site?

Follow the step-by-step instructions below to add this filter to your WordPress site.

  1. Copy the code you need from above.
  2. Go to your WordPress site's dashboard.
  3. Go to Plugins > Add New.
  4. Search for Code Snippets, then install and activate the plugin.
  5. Once installed and activated, go to Snippets in your dashboard menu.
  6. Click on Add New.
  7. Add a Title, which could be the title of this article.
  8. Paste the code you copied in step 1 to the Code section.
  9. Add a Description or Tags if you wish to do so. It is not required.
  10. Click on Save Changes and Activate to save the filter and activate it.
    1. Or click on Save Changes to save the filter and activate it later.
  11. Your action or filter is now stored and active on your site.

Still need help? Contact Us Contact Us