Support » Fixing WordPress » Category specific slider?

  • Resolved cruthas


    I was hoping someone might be able to point me in the right direction or provide some guidance. I am currently using a responsive slide plugin for my home page slider. It works great but it creates a custom post type. That is fine, but I would like, instead, to run my blog posts through it. Essentially I would like to create a category and name it “slider” and have the blog posts from that category use the slider. Any easy way to do that using my current setup (below) or can someone point me in the right direction on how to accomplish this? Thanks in advance! (website isn’t live, it’s on my computer’s localhost)

    Using shortcode on front page of theme

    <div id="flexfix" class="span11">
    <?php do_shortcode( '[responsive_slider]' ); ?>
    </div><!-- End Flexslider -->

    Responsive slider query

    function responsive_slider() {
    $slides = new WP_Query( array( 'post_type' => 'slides', 'order' => 'ASC', 'orderby' => 'menu_order' ) );
    if ( $slides->have_posts() ) : ?>
    <div class="responsive-slider flexslider">
    <ul class="slides">
    <?php while ( $slides->have_posts() ) : $slides->the_post(); ?>
    <div id="slide-<?php the_ID(); ?>" class="slide">
    <?php global $post; ?>
    <?php if ( has_post_thumbnail() ) : ?>
    <!--edited by david crothers 11/8/12-->
    <!--<?php echo get_post_meta( $post->ID, "_slide_link_url", true ); ?><?php the_title_attribute(); ?>-->
    <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
    <?php the_post_thumbnail( 'slide-thumbnail', array( 'class'	=> 'slide-thumbnail' ) ); ?>
    <h2 class="slide-title"><?php the_title()?></h2>
    <?php endif; ?>
    </div><!-- #slide-x -->
    <?php endwhile; ?>
    </div><!-- #featured-content -->
Viewing 3 replies - 1 through 3 (of 3 total)
  • Try changing this:

    $slides = new WP_Query( array( 'post_type' => 'slides', 'order' => 'ASC', 'orderby' => 'menu_order' ) );

    to this:

    $slides = new WP_Query( array( 'category' => 'Your Category', 'order' => 'ASC', 'orderby' => 'menu_order' ) );

    I can’t test that at the moment, but try it and let me know if it works.

    Also, if this code is in the plugin core files then make sure you make a backup of it. because your changes will be overwritten if you update that plugin.

    Yup, I ended up using

    $slides = new WP_Query( array( 'post_type' => 'post', 'category_name' => 'slider', 'order' => 'ASC', 'orderby' => 'menu_order' ) );

    works great. Codex is here:

    Thanks for the help!

    Glad you it worked out for you!

    If you could mark this thread as “Solved”, that would be great.
    (it’s in the sidebar on the right) 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Category specific slider?’ is closed to new replies.