Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Jquery slider to WordPress WordPress

Hi,

Coded the following slider


[code]
<?php $my_query = new WP_Query('category_name=slideshow&showposts=4'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; $countposts = 0; $countposts++; ?>
<?php if($countposts == 1) { ?>
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php $countposts++; ?>">
<a href="#fragment-<?php $countposts++; ?>">
<img src="http://95.154.242.30/~palaiolo/thumbs.php?src=<?php echo $image[0]; ?>&a=t&h=390&w=720" alt="" /><span><?php the_title(); ?></span></a></li>
<?php } ?>

<?php if($countposts != 1) { ?>
<li class="ui-tabs-nav-item" id="nav-fragment-<?php $countposts++; ?>">
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<a href="#fragment-<?php $countposts++; ?>">
<img src="http://95.154.242.30/~palaiolo/thumbs.php?src=<?php echo $image[0]; ?>&a=t&h=390&w=720" alt="" /><span><?php the_title(); ?></span></a></li>
<?php } ?>
<?php endwhile; wp_reset_query(); ?>

</ul>



<!-- First Content -->

<?php $my_query = new WP_Query('category_name=slideshow&showposts=4'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; $countposts2 = 0; $countposts2++; ?>
<div id="fragment-<?php $countposts2++; ?>" class="ui-tabs-panel" style="">

<img src="images/image1.jpg" alt="" />

<div class="info" >

<h2><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h2>

<p></p>

</div>

</div>

<?php endwhile; wp_reset_query(); ?>
[/code]



But seems not to work right. What is wrong with it?

Answers (4)

2012-11-07

Arnav Joy answers:

so what are you getting right now?


Basilis Kanonidis comments:

White blank page! :-)


Arnav Joy comments:

can you show me full code of the page as i not much clear about your work , what do you mean by

<!-- First Content -->

can you explain


Arnav Joy comments:

try this

<?php
$my_query = new WP_Query('category_name=slideshow&showposts=4');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; $countposts = 0; $countposts++; ?>
<?php if($countposts == 1) { ?>
<?php if (has_post_thumbnail( $post->ID ) ) ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php $countposts++; ?>">
<a href="#fragment-<?php $countposts++; ?>">
<img src="http://95.154.242.30/~palaiolo/thumbs.php?src=<?php echo $image[0]; ?>&a=t&h=390&w=720" alt="" /><span><?php the_title(); ?></span></a></li>
<?php } ?>

<?php if($countposts != 1) { ?>
<li class="ui-tabs-nav-item" id="nav-fragment-<?php $countposts++; ?>">
<?php if (has_post_thumbnail( $post->ID ) ) ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<a href="#fragment-<?php $countposts++; ?>">
<img src="http://95.154.242.30/~palaiolo/thumbs.php?src=<?php echo $image[0]; ?>&a=t&h=390&w=720" alt="" /><span><?php the_title(); ?></span></a></li>
<?php } ?>
<?php endwhile; wp_reset_query(); ?>

</ul>

2012-11-07

Dbranes answers:

Looks like there are problems with:

<?php if (has_post_thumbnail( $post->ID ) ): ?>


you are missing the endif's

<?php endif; ?>

(in 2 places)

2012-11-07

Abdelhadi Touil answers:

Hi.
I think your code should be rewrited. Please tell me wich silder you are using, is it:
[[LINK href="http://webdeveloperplus.com/jquery/featured-content-slider-using-jquery-ui/"]]http://webdeveloperplus.com/jquery/featured-content-slider-using-jquery-ui/[[/LINK]]
?
If yes, I can give you the correct code.
Now I going to work, if you find sollution with auther user here, so it's fine, if not I can continue with you after coming back from work.
Good luck.


Basilis Kanonidis comments:

Yes, this one is the slider :-)


Basilis Kanonidis comments:

I am waiting, when you are done! :-)


Abdelhadi Touil comments:

Back.
I'v rebuilt the full code; try this I hope it works:
<div id="featured">
<?php $my_query = new WP_Query('category_name=slideshow&posts_per_page=4'); ?>
<ul class="ui-tabs-nav">
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php the_ID(); ?>"><a href="#fragment-<?php the_ID(); ?>">
<?php if (has_post_thumbnail($post->ID)) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<img src="http://95.154.242.30/~palaiolo/thumbs.php?src=<?php echo $image[0]; ?>&a=t&h=80&w=50" alt="" />
<?php } ?>
<span><?php the_title(); ?></span></a></li>
<?php endwhile; wp_reset_query(); ?>
</ul>

<?php $my_query = new WP_Query('category_name=slideshow&posts_per_page=4'); while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div id="fragment-<?php the_ID(); ?>" class="ui-tabs-panel" style="">
<?php if (has_post_thumbnail($post->ID)) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<img src="http://95.154.242.30/~palaiolo/thumbs.php?src=<?php echo $image[0]; ?>&a=t&h=390&w=720" alt="" />
<?php } ?>
<div class="info" >
<h2><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h2>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>

Good luck.

2012-11-07

Martin Pham answers:

Hi Basilis,
please try this code to be optimized.

<?php
$my_query = new WP_Query('category_name=slideshow&showposts=4');
if($my_query->have_posts()) : while($my_query->have_posts()) : $my_query->the_post();
?>
<ul>
<?php $do_not_duplicate = $post->ID;
if($my_query->current_post == 0) {
if (has_post_thumbnail( $post->ID ) ) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
?>
<li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php $my_query->current_post; ?>">
<a href="#fragment-<?php $my_query->current_post; ?>">
<img src="http://95.154.242.30/~palaiolo/thumbs.php?src=<?php echo $image[0]; ?>&a=t&h=390&w=720" alt="" /><span><?php the_title(); ?></span></a></li>
<?php }} else { ?>
<li class="ui-tabs-nav-item" id="nav-fragment-<?php $my_query->current_post; ?>">
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<a href="#fragment-<?php $my_query->current_post; ?>">
<img src="http://95.154.242.30/~palaiolo/thumbs.php?src=<?php echo $image[0]; ?>&a=t&h=390&w=720" alt="" /><span><?php the_title(); ?></span></a></li>
<?php }
endwhile;
?>
</ul>
<?php
endif;
wp_reset_query();
?>