Hi
I am using jcarousel to scroll through project images if there are more than 3 portfolio items to view, therefore I need to somehow create a statement that says = if more than 3 custom post types items in a certain taxonomy put in
<ul id='mycarousel' class='jcarousel-skin-tango'>
else put in
<ul>
This is the code I have currently ....
<?php
$exclude_post = $post->ID;
$args = array( 'post_type' => 'portfolio', 'portfolio_services'=> 'code-for-sustainable-homes', 'orderby' => 'rand', 'post__not_in' => array($exclude_post), 'posts_per_page' => get_option('square_num_portfolio_other') );
$wp_query = new WP_Query( $args );
while ($wp_query->have_posts()) : $wp_query->the_post();
if ( get_post_meta( $post->ID, "exclude", true ) ) {
}else {
?>
<ul id='mycarousel' class='jcarousel-skin-tango'>
<li>
I guess I need a simple If/else statement but dont have time to work it out,
Many thanks
Jen
Arnav Joy answers:
try this
<?php
$exclude_post = $post->ID;
$args = array( 'post_type' => 'portfolio', 'portfolio_services'=> 'code-for-sustainable-homes', 'orderby' => 'rand', 'post__not_in' => array($exclude_post), 'posts_per_page' => get_option('square_num_portfolio_other') );
$wp_query = new WP_Query( $args );
$total_posts = $wp_query->found_posts;
if( $total_posts > 3 )
echo "<ul id='mycarousel' class='jcarousel-skin-tango'>";
else
echo "<ul>";
while ($wp_query->have_posts()) : $wp_query->the_post();
if ( get_post_meta( $post->ID, "exclude", true ) ) {
}else {
?>
<li>
Francisco Javier Carazo Gil answers:
You will need something like:
if (!get_post_meta( $post->ID, "exclude", true ) ):
?>
<ul id='mycarousel' class='jcarousel-skin-tango'>
<li>
...
<?php endif; ?>
Francisco Javier Carazo Gil comments:
Sorry I have an error. If you haven't nothing on the DB:
if (get_post_meta( $post->ID, "exclude", true ) != ""):
?>
<ul id='mycarousel' class='jcarousel-skin-tango'>
<li>
...
<?php endif; ?>
But if you use get_post_meta() and you save "true" or "false" in exclude:
if (get_post_meta( $post->ID, "exclude", true ) != "true"):
?>
<ul id='mycarousel' class='jcarousel-skin-tango'>
<li>
...
<?php endif; ?>