Skip n posts in recent post slider

Tutorial 3 posts from 2 participants
  • Started 5 years, 9 months ago ago by La M.
  • Replied 5 years, 8 months ago ago by Constantin
Viewing 4 posts - 1 through 4 (of 4 total)
  • #1957

    La M.

    I miss a functionality in this fantastic plugin. Is to skip n posts when you create a recent post slider. For instance, you may wish to show the latest post complete, but the next 5 in the slider only with the excerpt. This is now impossible. Do you think it would be interesting for new releases?




    It isn’t impossible, you just need to put some code in your theme functions.php. Version 3 has a slide content filter implemented that allows you to modify the content. This is how to use it:

     * Return different slide content for slides
     * @param string $slide_content - the slide text
     * @param object $slide_post - the slide post object
     * @param object $slider_post - the slider post object
    function my_content_processing_func( $slide_content, $slide_post, $slider_post ){
    	// do this for just one slider
    	// change 67 with your own slider ID that you want this to work for
    	if( 67 != $slider_post->ID ){
    		return $slide_content;
    	$index = $slider_post->current_slide;
    	// newest post is first
    	if( 0 == $index ){
    		return $slide_content;
    		// for all others, return the excerpt
    		$excerpt = $slide_post->post_excerpt;
    		// here, maybe format the excerpt
    		return $excerpt;
    add_filter( 'the_fa_content', 'my_content_processing_func', 10, 3 );

    The code above should be placed into your WP theme functions.php file. Also, you will have to change 67 to your own slider ID that you want to process the slides for.


    La M.

    Thank you Constantin.
    Do you know how should be the filter to just skip the first one?
    Thank you



    Sorry to be so late with an answer, something must be wrong with our forums because we didn’t get a notice about your last post.
    Not sure though that I understand your second question, the code above returns the content only for the first slide, all others have the excerpt returned for them. Isn’t this what you were after?

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.