WordPress.org

Ready to get started?Download WordPress

Forums

A shortcode slider with Flexslider (1 post)

  1. another day
    Member
    Posted 2 years ago #

    Hello!

    I try to make a shotcode slider with flexslider using this tutorial:

    So i want to modify the post query to implement a category option in my shortcode.

    Someone can help me please?

    I try that:

    function e_insert_slider($atts, $content=null){
    
    $slider= e_get_slider();
    
    $categoryname = $content;
    
    return $slider;
    
    }
    
    add_shortcode('e_slider', 'e_insert_slider');
    function e_get_slider(){
    
    	$slider= '<div class="flexslider">
    	  <ul class="slides">';
    
    	// assign the variable as current category
    
    // run the query
    query_posts("&categoryname=".$categoryname);
    
    	if (have_posts()) : while (have_posts()) : the_post();
    		$img= get_the_post_thumbnail( $post->ID, 'large' );
    
    		$slider.='<li>'.$img.'</li>';
    
    	endwhile; endif; wp_reset_query();
    
    	$slider.= '</ul>
    	</div></br>';
    
    	return $slider;
    }
    
    /**add template tag- for use in themes**/
    
    function e_slider(){
    
    	print e_get_slider();
    }

Topic Closed

This topic has been closed to new replies.

About this Topic