get_news_for_category

Documentation/get_news_for_category

 

Description

The most appropriate use for get_news_for_category is to create an array of news posts that belong to the category defined.

 

Usage

<?php if (function_exists('get_news_for_category')) 
$loop = get_news_for_category($category_id, $type, $days_ago, $posts_per_page); ?>

 

Parameters

$category_id

(integer) (optional) The ID of the category you’d like to fetch. If no ID is provided and the current page is a category, the current category ID of the current page will be used.

 

$type

(string) (optional) (popular, recent) The type of search for news we’re doing. Either ‘popular’ or ‘recent’

Default: recent

 

$days_ago

(integer) (optional) The amount of days to search back through the news, if no quantity of days is provided, news can be retrieved as far back as possible.

 

$posts_per_page

(integer) (optional) The quantity of news posts to return.

Default: 20

 

Examples

Get popular news for the current category from the last 2 days and output the title of each article

 

<?php
if (function_exists('get_news_for_category')) 
$loop = get_news_for_category($category_id, $type, $days_ago, $posts_per_page);

/* Start the Loop */ 
while ( $loop->have_posts() ) : $loop->the_post(); 

     echo $post->post_title; 

endwhile;
?>

Return

Basic values: http://codex.wordpress.org/Function_Reference/get_post#Return

Additional values added by WP News Aggregator: http://wpnewsaggregator.com/documentation/#template_tags

Web Statistics