Support » Fixing WordPress » Hooking your slider up to the backend of wordpress

  • If you have used a slider or similar API then you know that having to rewrite html is a pain in the butt to add or remove slider images.

    Most slider APIs have you call an unordered list as your slider…and a list item is the actual image in the slider.


    <ul class="slider">
    	<li><img src=""/></li>
    	<li><img src=""/></li>
    	<li><img src=""/></li>

    If you wanted to hook this up very easily to the wordpress backend you could using

    <div class="slider">
    // The Query
    $the_query = new WP_Query( $args );
    // The Loop
    while ( $the_query->have_posts() ) : $the_query->the_post();
    	echo '<li>' . if ( has_post_thumbnail() ) {
    }  . '</li>';
    // Reset Post Data

    If you pass $args an argument for say…a category slider posts See WP_Query and you make sure each post that was in that category had a featured image. Then you effectively have an easy way to add & upload slider images.

    Dont forget to add add_theme_support( 'post-thumbnails' ); to your functions.php file.

    Thank you, wordpress users.

  • The topic ‘Hooking your slider up to the backend of wordpress’ is closed to new replies.