I have a function that uses wp_get_recent_posts()
I need to use this same function on my search page but am having problems adding the search parameter to the $args
array.
Does anyone know if this is possible and if so how to implement it?
here is my function
function recent_articles_grid( $atts ) {
extract( shortcode_atts( array (
'numberposts' => 6,
'offset' => 0,
'featured' => null,
'trending' => null,
'showdate' => null,
'category' => null,
'showauthor' => null,
'init' => 1,
'searchterm' => null
), $atts ) );
$args = array(
'numberposts' => $numberposts,
'offset' => $offset,
'category__not_in' => array(391),
'category' => $category,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish'
);
$recent_posts = wp_get_recent_posts( $args, ARRAY_A );
... additional code ...
}
's'
argument ofwp_get_recent_posts()
(or justget_posts()
) to the search term, but yeah, I wouldn't suggest this method of display search results.