• Resolved jaysonbrown

    (@jaysonbrown)


    Hi,

    I am using a plug-in; “d13slideshow” which allows you to add 1 post slideshow displaying any category, it works, but I would like to have multiple sliders anywhere so I use;

    <?php
    $args = array(
    'numberposts' => 10,
    'category' => 9,
    'orderby' => rand
    );
    
    $lastposts = get_posts($args);
    foreach($lastposts as $post) :
    setup_postdata($post);
    ?>
            <?php
    $ID_Array[]=$post->ID;
    ?>
            <?php endforeach; ?>
            <?php d13slideshow(array($ID_Array[0], $ID_Array[1], $ID_Array[2], $ID_Array[3], $ID_Array[4], $ID_Array[5], $ID_Array[6], $ID_Array[7], $ID_Array[8], $ID_Array[9])); ?>

    However I would like to place this code in category.php, and have “ ‘category’ => 9, ” dynamically detect the category, so I found this;

    <?php
    if (is_category()) {
    global $wp_query;
    $cat_obj = $wp_query->get_queried_object();
    echo $cat_obj->name . " is id ". $cat_obj->term_id;
    }
       ?>

    That works, but how can I combine this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter jaysonbrown

    (@jaysonbrown)

    .

    Thread Starter jaysonbrown

    (@jaysonbrown)

    ..

    Thread Starter jaysonbrown

    (@jaysonbrown)

    … lol

    Thread Starter jaysonbrown

    (@jaysonbrown)

    Got so fed up with trying to figure out how to code this simple PHP function, I contacted justanswerDOTcom and they solved the issue within 25 minutes for $22 USD. Well, that works for me!

    <?php
    function getCurrentCategoryId()
    {
    	if (is_category()) {
    		global $wp_query;
    		$cat_obj = $wp_query->get_queried_object();
    		return $cat_obj->term_id;
    	}
    	return -1;
    }
    
    $args = array(
    
    'numberposts' => 3,
    
    'category' => getCurrentCategoryId(),
    
    'orderby' => rand
    
    );
    
    $lastposts = get_posts($args);
    
    foreach($lastposts as $post) :
    
    setup_postdata($post);
    
    ?>
    
    <?php
    
    $ID_Array[]=$post->ID;
    
    ?>
    
    <?php endforeach; ?>
    
    <?php d13slideshow(array($ID_Array[0], $ID_Array[1], $ID_Array[2], $ID_Array[3], $ID_Array[4], $ID_Array[5], $ID_Array[6], $ID_Array[7], $ID_Array[8], $ID_Array[9])); ?>
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘[Plugin: d13slideshow] Multiple sliders, code works stumped on making it dynamic’ is closed to new replies.