I got a tricky question. I have created a custom post type whose posts I would like to display in a scrolling carousel. The carousel will only display the title, the excerpt and a “read more” button. The “read more” button displays the full post in a FancyBox.
Here is my code so far:
<ul id="slider2">
<?php
$args = array( 'post_type' => 'jobs', 'posts_per_page' => 15 , 'order' => 'ASC' );
$loop = new WP_Query( $args ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li>
<h4><?php the_title(); ?></h4>
<?php echo excerpt( '30' ); ?>
<a class="various1" href="#inline1" title="Lorem ipsum dolor sit amet">Read more →</a>
<div style="display: none;">
<div id="inline1" style="width:400px;height:100px;overflow:auto;"><?php the_content(); ?></div>
</div>
</li>
<?php endwhile; wp_reset_query(); ?>
</ul>
Everything is working nicely. The Carousel and FancyBox scripts are loading correctly but the FancyBox is displaying the wrong content.
Any help/advice would be great.
The issue is that you are declaring a same ID for every DIV in the LOOP. What you need is to do something like this:
I’ve change the
inline1
withinline[?php echo $i; ?]
.Hope this solve your problem.
Hope This will help
If your fancybox content isn’t what you want then the issue is most likely with your jquery or plugin usage.
If you’re using the “fancybox for wordpress” plugin, it’s been my experience that it doesn’t handle inline content well by default. You may need to define an extra call within the plugin.
It looks like you are mirroring the inline usage on the fancybox.net site.
You should try implementing a similar call to fancybox that is used there:
this is the call for this html example:
Where
various1
is the id of the link and fancybox displays the content of the element that matches the id of the href attribute in the link (in this casehref="#inline1"
).