0

My question is, how do I put a limit on the amount of featured content that shows up on my slider on the front page.

I'm using Dynamic News theme and it has a slider built in. However I want to limit on how many pieces of featured content actually show up on the slider.

The site is http://www.kurdang.com

As you can you on the front page it has like 20 slides but I would like to reduce that to like 5.

Could anybody please help or lead me to the right direction.

Thank you very much in advance.

3
  • 1
    You should ask the theme developer, it depends how it is setup. I mean the WP answer would be 'posts_per_page' => 5, within the slider query array but without the slider code it would be hard to tell you what to do and where to do it
    – NickFMC
    Jan 9, 2015 at 20:41
  • I've tried contacting the theme developer but unfortunately haven't received a reply. And where could I pull the slider code from for you to have a look at? Thanks Jan 9, 2015 at 20:48
  • Add the slider code to your question.
    – gdaniel
    Jan 9, 2015 at 20:57

1 Answer 1

4

I installed the Lite version of this theme on a test site and dug around. The function that generates the slider doesn't provide any useful filters. However, it does store the IDs of the featured posts in a transient, so you could use the pre_set_site_transient_' . $transient and transient_' . $transient filters to reduce the number of posts. It also respects the value 'max_posts' as declared in the theme, so you could replace this. Both would required creating a child theme (or, in the case of the former, a plugin that allows you to add hooks would also suffice).

Transient method:

add_filter( 'pre_set_site_transient_featured_content_ids', 'wpse174427_transient_method' );
add_filter( 'transient_featured_content_ids', 'wpse174427_transient_method' );
function wpse174427_transient_method( $value ) {
  return array_slice( $value, 0, 5 );
}

Theme support method:

add_action( 'after_setup_theme', 'wpse174427_themesupport_method', 11 );
function wpse174427_themesupport_method() {
  remove_theme_support( 'featured-content' );
  add_theme_support( 'featured-content', array( 'featured_content_filter' => 'dynamicnews_get_featured_content', 'max_posts' => 5 ) );
}
2
  • Hi thanks for the great info and going through the theme. But where would I add those 2 snippets of codes to? What files? Thanks Jan 9, 2015 at 21:35
  • FIXED IT! THANK YOU SO MUCH!! YOU ARE THE BEST HAHA!!! Jan 9, 2015 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.